package com.handinfo.game;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Vector;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextField;

import com.handinfo.engine.AbstractGameScene;
import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.Actor;
import com.handinfo.engine.Animation;
import com.handinfo.engine.GameMIDlet;
import com.handinfo.engine.GameManager;
import com.handinfo.engine.Music;
import com.handinfo.engine.net.BaseConnection;
import com.handinfo.engine.net.GameProtocol;
import com.handinfo.engine.resource.ObjectAdapter;
import com.handinfo.engine.resource.ResHead;
import com.handinfo.engine.resource.ResourceManager;
import com.handinfo.engine.resource.SerializeableImage;
import com.handinfo.uimenu.AbsHyperLinker;
import com.handinfo.uimenu.UIListener;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIMessageBox;
import com.handinfo.uimenu.UITools;
import com.handinfo.uimenu.UIWindowFactory;
import com.handinfo.uimenu.UiInteractMenu;
import com.handinfo.uimenu.window.ActorItemLBHandler;
import com.handinfo.uimenu.window.UIActivity;
import com.handinfo.uimenu.window.UIActorItemDetail;
import com.handinfo.uimenu.window.UIAnnouncement;
import com.handinfo.uimenu.window.UIAttribute;
import com.handinfo.uimenu.window.UIAuction;
import com.handinfo.uimenu.window.UIAuctionDetail;
import com.handinfo.uimenu.window.UIAuctionList;
import com.handinfo.uimenu.window.UIAuctionSail;
import com.handinfo.uimenu.window.UIAutoAddFriend;
import com.handinfo.uimenu.window.UIAutoHangUp;
import com.handinfo.uimenu.window.UIBag;
import com.handinfo.uimenu.window.UIBattlefieldWindow;
import com.handinfo.uimenu.window.UICaveWorldWindow;
import com.handinfo.uimenu.window.UIChongzhi;
import com.handinfo.uimenu.window.UIDeal;
import com.handinfo.uimenu.window.UIFamilyWindow;
import com.handinfo.uimenu.window.UIFbactivity;
import com.handinfo.uimenu.window.UIGameCarbonWindow;
import com.handinfo.uimenu.window.UIGonglue;
import com.handinfo.uimenu.window.UILearnCollection;
import com.handinfo.uimenu.window.UIMail;
import com.handinfo.uimenu.window.UIMailList;
import com.handinfo.uimenu.window.UIMain;
import com.handinfo.uimenu.window.UIMarket;
import com.handinfo.uimenu.window.UIMultiMoney;
import com.handinfo.uimenu.window.UINpcShop;
import com.handinfo.uimenu.window.UIQianghua;
import com.handinfo.uimenu.window.UIRankingLists;
import com.handinfo.uimenu.window.UISetMarco;
import com.handinfo.uimenu.window.UISetShortCut;
import com.handinfo.uimenu.window.UIShowData;
import com.handinfo.uimenu.window.UISkill;
import com.handinfo.uimenu.window.UISkillDetail;
import com.handinfo.uimenu.window.UISocialWindow;
import com.handinfo.uimenu.window.UITeamWindow;
import com.handinfo.uimenu.window.UIUserManager;
import com.handinfo.uimenu.window.UIWanted;
import com.handinfo.util.ArrayList;
import com.handinfo.util.Tools;

public class GameScene extends AbstractGameScene implements CommandListener
{

	public String m_word_repeat = null;
	public boolean m_repeat = false;// 是否重复登录

	public AbstractGameActor m_controlledActor;
	public static Actor s_targetFrame; // 当前目标的标记框
	public static final String URL_ANIM_TARGETFRAME = "/anim/mubiao.anim";

	public static GameScene s_instance;

	// 进度条相关 2011.11.06 xujianping//
	public static final String LOADING_IMG_BAR = "/img/loading.png"; // 进度条框
	public static final String LOADING_IMG_GUANG = "/img/loading_guang.png"; // 进度光
	public static Image s_img_loadingFrame;
	public static Image s_img_loadingGuang;

	public GameScene()
	{
		super();
		s_instance = this;
		m_script = new GameScript(this);
	}

	/** 是否为弹出快捷菜单 */
	public boolean m_contextmenu = false;
	/** 申请组队 */
	public final byte CONTEXTMENU_TYPE_REQUESTTEAM = 0;
	/** 跟随队长 */
	public final byte CONTEXTMENU_TYPE_FOLLOWLEADER = 1;
	/** 转移队长 */
	public final byte CONTEXTMENU_TYPE_CHANGELEADER = 2;
	/** 退出组队 */
	public final byte CONTEXTMENU_TYPE_QUITTEAM = 3;
	/** 快捷菜单类型总数 */
	public final byte CONTEXTMENU_TYPE_COUNT = 4;
	/** 快捷菜单下标 */
	public byte m_contextmenu_index = 0;

	public final String[] CONTEXTMENU_STRING = { "申请组队", "跟随队长", "转移队长", "退出组队" };

	/** 测试 技能菜单 */
	public boolean m_test_skillMenu = false;
	public static final int TEST_SKILLMENU_COUNT_PER_PAGE = 10;
	public int m_test_skillMenu_curLine = 0;
	public int m_test_skillMenu_index = 0;

	// public boolean m_request_team = false;

	public void init()
	{
		super.init();
		// 场景初始化
		m_dynamic_actors.removeAllElements();
		m_activeList.removeAllElements();
		m_drawList.removeAllElements();
		m_damageMiss_list.removeAllElements();
		m_damageNum_list.removeAllElements();
		m_targetEnemyList.removeAllElements();
		m_targetFriendList.removeAllElements();
		// 场景中关于玩家角色的初始化
		ActorRole role = GameManager.getInstance().m_role;
		role.m_posX = role.m_prevPosX = GameManager.getInstance().m_role_x;
		role.m_posY = role.m_prevPosY = GameManager.getInstance().m_role_y;
		Tools.debugPrintln("GameScene init role status : " + role.m_status);
		initRoleAnims();
		if (role.m_status == ActorRole.ACTOR_STATUS_ROLE_DEAD) {
			role.setAction(ActorRole.ACTION_DEAD1 * ActorRole.DIRECT_NUM, 0, 0, false, true);
		}
		else if (GameManager.getInstance().m_role.m_isride) {
			role.setAction((ActorRole.ACTION_RIDESTAND1 + GameManager.getInstance().m_role.m_ride.m_rideType - 1)
					* ActorRole.DIRECT_NUM
					+ GameManager.getInstance().m_role.m_direct, 0, 0, true, true);
		}
		else {
			role.setAction(ActorRole.ACTION_STAND, 0, 0, true, true);
		}
		role.activate();
		role.m_targetActor = null;
		m_controlledActor = role;
		m_focusActor = role;
		addDynamicActor(role);
		UIMain.updateExp();

		// 初始化宏
		// GameManager.getInstance().m_game_macro = new
		// GameMacro[GameManager.AMOUNT_MACRO];
		// GameManager.getInstance().m_game_macro[0] = new GameMacro();

		// 聊天
		// ChatItem[] items = ChatItem.getTestChaTItems();
		// Tools.debugPrintln("调试，测试聊天显示");
		// for (int i = 0; i < items.length; i++) {
		// GameManager.getInstance().m_role.m_list_chats.addElement(items[i]);
		// }

		// initShortcut();
		Tools.debugPrintln("初始化UI");
		Tools.debugPrintln("Open Main Ui");
		UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MAIN);

		//重置显示数据
		if(GameManager.getInstance().m_showData != null){
			GameManager.getInstance().m_showData.resetShowData();
		}
		// GameManager.getInstance().m_loading_screen.m_progress = 4;

		// 预先绘制
		updateLogic();
		updateCamera();
		updateActorList();
		draw(m_screen.getGraphics());
		m_isFade = true;
		// #if lucency == "YES"
		m_fadeId = Tools.getRandom(0, 3);
		// #else
		// # m_fadeId = Tools.getRandom(1, 3);
		// #endif
		GameManager.getInstance().m_game_message.sendChangeFinished();
		GameManager.getInstance().resetConnectionIdle();

		if (GameManager.getInstance().m_role.m_pathfinding_start) {
			GameManager.getInstance().m_role.m_pathfinding_pause = false;
		}
	}

	public void initRoleAnims()
	{
		GameManager.getInstance().m_role.m_refsResHead[1] = null;
		GameManager.getInstance().m_role.m_refsResHead[2] = null;

		byte type = 0;// 换装
		ActorItem[] items = GameManager.getInstance().m_role.m_bag_equipment;
		ActorItem[] _items = new ActorItem[2];// 0武器 1时装
		_items[0] = items[ActorItem.INDEX_EQUIP_WEAPON];
		_items[1] = items[ActorItem.INDEX_EQUIPMENT_DRESS];
		if (_items[0] != null) {// 有装备武器
			GameManager.getInstance().m_role.EquipWeapon(_items[0], type);
		}

		int sex = GameManager.getInstance().m_role.m_sex - 1;
		int vocation = GameManager.getInstance().m_role.m_vocation[0] - 1;
		int race = GameManager.getInstance().m_role.m_race - 1;
		String url = ObjectAdapter.DIR_ANIM.concat(GameManager.s_roleModemList[sex][vocation][race]).concat(
				ObjectAdapter.EXTENSION_ANIM);
		ResHead head = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, url, 1);
		Animation anim = (Animation) (ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_scene, head));
		GameManager.getInstance().m_role.m_refsResHead[1] = head;
		if (anim != null && anim.m_loadFinished) {
			GameManager.getInstance().m_role.m_anim = anim;
			GameManager.getInstance().m_role.m_anims[1] = anim;
		}
		else {
			GameManager.getInstance().m_role.m_anim = GameManager.getInstance().m_shadowAnimation;
			GameManager.getInstance().m_role.m_anims[1] = GameManager.getInstance().m_shadowAnimation;
		}
		if (_items[1] != null) {// 有装备时装
			GameManager.getInstance().m_role.EquipDress(_items[1], type);
		}
		head = GameManager.getInstance().m_role.m_refsResHead[0];
		if (head != null) {// 有坐骑
			anim = (Animation) (ResourceManager.getInstance().loadResource(GameManager.getInstance().m_resource_scene,
					head));
			if (anim != null && anim.m_loadFinished) {
				GameManager.getInstance().m_role.m_anims[0] = anim;
			}
		}
	}

	public void run()
	{
		super.run();
		UIManager.getInstance().removeAllWindows();
		if(GameManager.getInstance().m_showData != null){
			GameManager.getInstance().m_showData.resetShowData();
		}
		removeRoleByID(GameManager.getInstance().m_role.m_gameID);
		GameManager.getInstance().m_role.reset();
	}

	public static void initStaticResource()
	{
		ResHead head = null;
		// o
		// 进度条相关 初始化资源
		// 2011.11.06 xujianping
		//
		// 进度框
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, LOADING_IMG_BAR, 1);
		s_img_loadingFrame = ((SerializeableImage) ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_static, head)).m_image;
		// 进度更新光图标
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, LOADING_IMG_GUANG, 1);
		s_img_loadingGuang = ((SerializeableImage) ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_static, head)).m_image;
		// o

		// 普通数字
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_NUM, 1);
		s_img_num = ((SerializeableImage) ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_static, head)).m_image;
		//
		// 伤害数字
		if (s_img_damageNum == null) {
			s_img_damageNum = new Image[URL_IMG_DAMAGENUM.length];
			for (int i = 0; i < s_img_damageNum.length; i++) {
				head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_DAMAGENUM[i], 1);
				s_img_damageNum[i] = ((SerializeableImage) ResourceManager.getInstance().loadResource(
						GameManager.getInstance().m_resource_static, head)).m_image;
			}
		}

		// NPC功能图标
		s_img_f_icon = new Image[4];
		s_img_f_icon[0] = Tools.createImage("/img/newui/f_icon_1.png");
		s_img_f_icon[1] = Tools.createImage("/img/newui/f_icon_2.png");
		s_img_f_icon[2] = Tools.createImage("/img/newui/f_icon_3.png");
		s_img_f_icon[3] = Tools.createImage("/img/newui/f_icon_4.png");

		s_img_z_icon = new Image[3];
		s_img_z_icon[0] = Tools.createImage("/img/newui/dt.png");
		s_img_z_icon[1] = Tools.createImage("/img/newui/kl.png");
		s_img_z_icon[2] = Tools.createImage("/img/newui/ts.png");

		s_img_th_icon = new Image[5];
		s_img_th_icon[ActorNPC.IMG_HS_Y_QUESTION_MARK] = Tools.createImage("/img/newui/th_y_q.png");
		s_img_th_icon[ActorNPC.IMG_HS_B_QUESTION_MARK] = Tools.createImage("/img/newui/th_b_q.png");
		s_img_th_icon[ActorNPC.IMG_HS_Y_EXCLAMATION_MARK] = Tools.createImage("/img/newui/th_y_e.png");
		s_img_th_icon[ActorNPC.IMG_HS_B_EXCLAMATION_MARK] = Tools.createImage("/img/newui/th_b_e.png");
		s_img_th_icon[ActorNPC.IMG_HS_G_QUESTION_MARK] = Tools.createImage("/img/newui/th_g_q.png");

		s_img_v_icon = new Image[VIP_ICON_AMOUNT];
		for (byte i = 0; i < VIP_ICON_AMOUNT; i++) {
			s_img_v_icon[i] = Tools.createImage("/img/newui/vip" + (i + 1) + ".png");
		}

		// 图标
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_ICON, 1);
		s_img_icon = ((SerializeableImage) ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_static, head)).m_image;
		// 图标
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_ICON_COVER, 1);
		s_img_icon_cover = ((SerializeableImage) ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_static, head)).m_image;

		// 光效
		GameEffect.initStaticResource();

		// 标记框
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, URL_ANIM_TARGETFRAME, 1);
		Animation anim = (Animation) (ResourceManager.getInstance().loadResource(
				GameManager.getInstance().m_resource_static, head));
		s_targetFrame = new Actor(anim);

		// buffer图标
		ActorBuffer.initStaticResource();

		// NPC头上状态图标
		GameManager.getInstance().img_head_status = new Image[ActorNPC.IMG_HS_AMOUNT];
		GameManager.getInstance().img_head_status[ActorNPC.IMG_HS_Y_QUESTION_MARK] = Tools.createImage("/img/hw.png");
		GameManager.getInstance().img_head_status[ActorNPC.IMG_HS_B_QUESTION_MARK] = Tools.createImage("/img/lw.png");
		GameManager.getInstance().img_head_status[ActorNPC.IMG_HS_Y_EXCLAMATION_MARK] = Tools
				.createImage("/img/hg.png");
		GameManager.getInstance().img_head_status[ActorNPC.IMG_HS_B_EXCLAMATION_MARK] = Tools
				.createImage("/img/lg.png");
		GameManager.getInstance().img_head_status[ActorNPC.IMG_HS_G_QUESTION_MARK] = Tools.createImage("/img/hhw.png");

		GameManager.getInstance().img_softkey = UIManager.getInstance().coinImage(UIManager.RES_BUTTON_LEFT);
		GameManager.getInstance().img_corner = UIManager.getInstance().coinImage(UIManager.RES_BORDER_CORNER);
		GameManager.getInstance().img_select = UIManager.getInstance().coinImage(UIManager.RES_SELECT_BOX);
		GameManager.getInstance().img_time_bar_left = UIManager.getInstance().coinImage(UIManager.RES_TIME_BAR_LEFT);
		GameManager.getInstance().img_time_bar_right = UIManager.getInstance()
				.coinImage(UIManager.RES_TIME_BAR_RIGHT);
		GameManager.getInstance().img_page_corner = UIManager.getInstance().coinImage(UIManager.RES_SHORTCUT_ARROW1);
		GameManager.getInstance().img_casting_bar = UIManager.getInstance().coinImage(UIManager.RES_CASTING_BAR);

		s_img_map_bg = Tools.createImage(URL_IMG_MAP_BG);
		s_img_map_place = Tools.createImage(URL_IMG_MAP_PLACE);
		s_img_map_coord = Tools.createImage(URL_IMG_MAP_COORD);

		s_img_cursor_corner = Tools.createImage("/login/guangbiao2.png");
		s_img_cursor_side = Tools.createImage("/login/guangbiao1.png");
	}

	public static void disposeStaticResource()
	{
		ResHead head = null;
		// o
		// 进度条相关 初始化资源
		// 2011.11.06 xujianping
		//
		// 进度框
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, LOADING_IMG_BAR, 1);
		ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
		s_img_loadingFrame = null;
		// 进度更新光图标
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, LOADING_IMG_GUANG, 1);
		ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
		s_img_loadingGuang = null;
		// o

		// 普通数字
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_NUM, 1);
		ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
		s_img_num = null;

		// 伤害数字
		if (s_img_damageNum != null) {
			for (int i = 0; i < s_img_damageNum.length; i++) {
				head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_DAMAGENUM[i], 1);
				ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
				s_img_damageNum[i] = null;
			}
			s_img_damageNum = null;
		}

		// 图标
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_ICON, 1);
		ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
		s_img_icon = null;
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_PNG, URL_IMG_ICON_COVER, 1);
		ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
		s_img_icon_cover = null;

		// 光效
		GameEffect.disposeStaticResource();

		// 标记框
		head = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, URL_ANIM_TARGETFRAME, 1);
		ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_static, head);
		s_targetFrame.dispose();
		s_targetFrame = null;

		// buffer图标
		ActorBuffer.disposeStaticResource();
	}

	public void updateLogic()
	{
		super.updateLogic();
		refreshThumbnail();
		// GameManager.getInstance().m_game_macro[0].doAction();
		UIMain.updateThumbnail();
		// GameManager.m_isControlledByUi = UiManager.s_isControlledByUi;
	}

	// private int m_thumbnail_x = (AbstractGameScreen.SCREEN_WIDTH -
	// THUMBNAIL_SHOW_WIDTH) >> 1;
	// private int m_thumbnail_y = (AbstractGameScreen.SCREEN_HEIGHT -
	// THUMBNAIL_SHOW_HEIGHT) >> 1;
	public Vector m_thumbnail_list = new Vector();// 缩略图列表
	public boolean m_refresh_thumbnail = false;
	// public final int THUMBNAIL_SEARCH_WIDTH = 330;// 小地图搜索范围宽度
	// public final int THUMBNAIL_SEARCH_HEIGHT = 330;// 小地图搜索范围高度
	public final int THUMBNAIL_SHOW_WIDTH = 66;// 小地图高度
	public final int THUMBNAIL_SHOW_HEIGHT = 66;// 小地图宽度

	// public final int THUMBNAIL_OFFSET_X = (THUMBNAIL_SEARCH_WIDTH -
	// AbstractGameScreen.SCREEN_WIDTH) >> 1;
	// public final int THUMBNAIL_OFFSET_Y = (THUMBNAIL_SEARCH_HEIGHT -
	// AbstractGameScreen.SCREEN_HEIGHT) >> 1;
	// public final byte THUMBNAIL_SCALING = THUMBNAIL_SEARCH_WIDTH /
	// THUMBNAIL_SHOW_WIDTH;

	/**
	 * 更新缩略图
	 */
	public void refreshThumbnail()
	{
		// 敌人红, NPC黄, 自己白, 队友绿, 门元件蓝
		int search_w = m_bg.m_columns * m_bg.m_tileW;
		int search_h = m_bg.m_rows * m_bg.m_tileH;
		int scaling_w = search_w / (THUMBNAIL_SHOW_WIDTH - 6);
		int scaling_h = search_h / (THUMBNAIL_SHOW_HEIGHT - 6);

		int sx = 0;
		int sy = 0;
		int ex = sx + search_w;
		int ey = sy + search_h;

		ArrayList actorList = GameManager.getInstance().m_scene.m_activeList;
		if (actorList != null && actorList.size() > 0) {
			Vector team = GameManager.getInstance().m_role.m_roleTeam;
			for (int i = 0; i < actorList.size(); i++) {
				if (actorList.elementAt(i) instanceof AbstractGameActor) {
					AbstractGameActor npc = (AbstractGameActor) actorList.elementAt(i);
					if (npc.m_posX >= sx && npc.m_posX <= ex && npc.m_posY >= sy && npc.m_posY <= ey) {
						if (npc.m_type == AbstractGameActor.ACTOR_TYPE_MONSTER) {
							npc.m_thumbnail_color = Tools.RED;
							// } else if (npc.m_type ==
							// AbstractGameActor.ACTOR_TYPE_NPC) {
							// if
							// (npc.checkTargetFriend(GameManager.getInstance().m_role))
							// {
							// npc.m_thumbnail_color = Tools.YELLOW;
							// } else {
							// npc.m_thumbnail_color = Tools.RED;
							// }
							// } else if (npc.m_type ==
							// AbstractGameActor.ACTOR_TYPE_GATE) {
							// npc.m_thumbnail_color = Tools.BLUE;
						}
						else if (npc.m_type == AbstractGameActor.ACTOR_TYPE_ROLE) {
							if (npc.m_gameID == GameManager.getInstance().m_role.m_gameID) {
								npc.m_thumbnail_color = Tools.WHITE;
							}
							else if (npc.checkTargetFriend(GameManager.getInstance().m_role)) {
								if (team != null && team.contains(npc)) {
									npc.m_thumbnail_color = Tools.BLACK;
								}
								else {
									npc.m_thumbnail_color = Tools.GREEN;
								}
							}
							else {
								npc.m_thumbnail_color = Tools.RED;
							}
						}
						else {
							continue;
						}
						npc.m_thumbnail_x = npc.m_posX / scaling_w + 3;
						npc.m_thumbnail_y = npc.m_posY / scaling_h + 3;
						if (m_refresh_thumbnail) {
							if (!m_thumbnail_list.contains(npc)) {
								m_thumbnail_list.addElement(npc);
							}
						}
					}
				}
			}
			// Vector team = GameManager.getInstance().m_role.m_roleTeam;
			// if (team != null) {
			// for (byte i = 0; i < team.size(); i++) {
			// ActorRole role = (ActorRole) team.elementAt(i);
			// if (role.m_gameID != GameManager.getInstance().m_role.m_gameID
			// && role.m_posX >= sx && role.m_posX <= ex
			// && role.m_posY >= sy && role.m_posY <= ey) {
			// role.m_thumbnail_color = Tools.BLACK;
			// role.m_thumbnail_x = (role.m_posX - ssx) / THUMBNAIL_SCALING;
			// role.m_thumbnail_y = (role.m_posY - ssy) / THUMBNAIL_SCALING;
			// m_thumbnail_list.addElement(role);
			// }
			// }
			// }
		}
		// else {
		// Tools.debugPrintln("更新缩略图失败 : " + actorList);
		// }
	}

	private final String PATHFINDING_WORD = "自动寻路中...";

	public void draw(Graphics g)
	{
		Graphics sg = m_screen.getGraphics();
		if (GameManager.getInstance().debugLogDraw(sg)) {
			return;
		}
		if (m_isPainting || m_isRepaintOnce) {
			super.draw(g);
			showEffect(g);
			showDamageNum(g);
			if (GameManager.getInstance().m_role.m_pathfinding_start
					&& !GameManager.getInstance().m_role.m_pathfinding_pause) {
				Tools.drawString(g, Tools.WHITE, Tools.BLACK, PATHFINDING_WORD, AbstractGameScreen.SCREEN_WIDTH >> 1,
						(AbstractGameScreen.SCREEN_HEIGHT >> 1)
								- (AbstractGameScreen.FONT_H >> 1), Tools.HCENTER_TOP);
			}
			m_isRepaintOnce = false;
		}
		sg.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		sg.drawImage(m_buffer, 0, 0, 0);

		UIManager.getInstance().logic();
		UIManager.getInstance().paint(sg);
		showMessage(sg);

		if (GameManager.getInstance().m_game_message.isLockNetwork()) {
			GameManager.getInstance().m_game_message.drawNetworkIcon(sg, GameManager.getInstance().img_lock_network,
					AbstractGameScreen.SCREEN_WIDTH >> 1,
					AbstractGameScreen.SCREEN_HEIGHT >> 1, m_timer % 4);
		}
	}

	public void keyLogic()
	{
		if (GameManager.getInstance().debugLogLogic()) {
			return;
		}
		// UIManager.getInstance().logic();
		// GameManager.getInstance().m_role.autoFight();
		if (++m_timer > 100000) {
			m_timer = 0;
		}
		if (m_interact_start) {
			if (--m_interact_time < 0) {
				endNPCInteract();
				GameManager.getInstance().m_role.stopCasting();
				GameManager.getInstance().m_role.stopCastingDescription();
				GameManager.getInstance().m_game_message
						.sendNPCInteractEnd(GameManager.getInstance().m_npc_window.m_read_spell_type);
				((GameScene) GameManager.getInstance().m_scene).m_controlledActor
						.stay(GameManager.getInstance().m_role.m_direct);
				goOnIteract();// 继续采集
			}
		}
		// if (m_ride_isStart) {
		// if (--m_ride_time < 0) {
		// m_ride_isStart = false;
		// m_ride_time = 0;
		// GameManager.getInstance().m_game_message.sendRideOver();
		// }
		// }
	}

	// private boolean m_ride_isStart = false;
	// private int m_ride_time = 0;

	// /**
	// * 坐骑计时
	// * @param time
	// */
	// public void startRideTime(int time)
	// {
	// m_ride_isStart = true;
	// m_ride_time = time;
	// }

	// public void endRideTime()
	// {
	// m_ride_isStart = false;
	// m_ride_time = 0;
	// }

	public void startNPCInteract(int time)
	{
		m_interact_start = true;
		m_interact_time = time;
		Tools.debugPrintln("采集倒计时设置 : " + time);
	}

	public void endNPCInteract()
	{
		Tools.debugPrintln("=======采集停止=======>");
		m_interact_time = 0;
		m_interact_start = false;
	}

	/**
	 * 自动采集
	 */
	public void goOnIteract()
	{
		Tools.debugPrintln("=======自动继续采集=======>");
		AbstractGameActor m_targetActor = GameManager.getInstance().m_role.m_targetActor;
		if (m_targetActor != null) {
			if (m_targetActor.m_type == ActorRole.ACTOR_TYPE_GATHERING) {
				GameManager.getInstance().m_role.clearPathfinding();
				GameManager.getInstance().m_role.clearFollowTarget();
				GameManager.getInstance().m_role.stopCasting();
				GameManager.getInstance().m_role.stopCastingDescription();
				GameManager.getInstance().m_game_message.sendNPCList(m_targetActor.m_gameID);
			}
		}
	}

	public boolean m_interact_start = false;// 是否采集
	private int m_interact_time = 0;// 采集时间
	public int m_timer = 0;

	public synchronized void dispose()
	{
		super.dispose();
		if (m_damageMiss_list != null) {
			m_damageMiss_list.removeAllElements();
			m_damageMiss_list = null;
		}
		if (m_damageNum_list != null) {
			m_damageNum_list.removeAllElements();
			m_damageNum_list = null;
		}
		if (m_messages != null) {
			m_messages.removeAllElements();
			m_messages = null;
		}
		if (m_targetFriendList != null) {
			m_targetFriendList.removeAllElements();
			m_targetFriendList = null;
		}
		if (m_targetEnemyList != null) {
			m_targetEnemyList.removeAllElements();
			m_targetEnemyList = null;
		}
		m_controlledActor = null;
	}

	/**
	 * 查找离自己最近的玩家
	 *
	 * @return 最近的玩家在m_drawlist中的下标
	 */
	public ActorRole recentActor()
	{
		ActorRole ar = null;
		ActorRole temp = null;
		if (m_drawList != null) {
			Actor actor;
			for (int i = 0, range = 0, last = 0; i < m_drawList.size(); i++) {
				actor = (Actor) m_drawList.elementAt(i);
				if (actor != null && actor instanceof ActorRole && actor != m_focusActor) {
					ar = (ActorRole) actor;
					range = ar.m_posX * ar.m_posX + ar.m_posY * ar.m_posY;
					if (last == 0 || range < last) {
						last = range;
						temp = ar;
					}
				}
			}
		}
		return temp;
	}

	/**
	 * 根据类型和ID获得Actor
	 */
	public Actor getActorById(int type, long id)
	{
		switch (type) {
			case AbstractGameActor.ACTOR_TYPE_ROLE:
				return getRoleByID(id);
			case AbstractGameActor.ACTOR_TYPE_NPC:
			case AbstractGameActor.ACTOR_TYPE_MONSTER:
			case AbstractGameActor.ACTOR_TYPE_GATE:
			case AbstractGameActor.ACTOR_TYPE_MAPPOINT:
			case AbstractGameActor.ACTOR_TYPE_RELIVE:
				return getNPCByID(id);
			default:
				break;
		}
		return null;
	}

	/**
	 * 根据类型和id移除Actor
	 *
	 * @param type
	 * @param id
	 */
	public Actor removeActorById(int type, long id)
	{
		switch (type) {
			case AbstractGameActor.ACTOR_TYPE_ROLE:
				return removeRoleByID(id);
			case AbstractGameActor.ACTOR_TYPE_GATE:
			case AbstractGameActor.ACTOR_TYPE_MAPPOINT:
			case AbstractGameActor.ACTOR_TYPE_RELIVE:
				return deactivateNPCByID(id);
			case AbstractGameActor.ACTOR_TYPE_NPC:
			case AbstractGameActor.ACTOR_TYPE_MONSTER:
			case AbstractGameActor.ACTOR_TYPE_ITEM:
			case AbstractGameActor.ACTOR_TYPE_GATHERING:
			case AbstractGameActor.ACTOR_TYPE_FAZHEN:
				return removeNPCByID(id);
			default:
				return null;
		}
	}

	/**
	 * 根据id获得role
	 *
	 * @param id
	 * @return
	 */
	public ActorRole getRoleByID(long id)
	{
		Actor actor;
		for (int i = 0; i < m_dynamic_actors.size(); i++) {
			actor = (Actor) m_dynamic_actors.elementAt(i);
			if (actor != null && actor instanceof ActorRole && actor.m_gameID == id) {
				return (ActorRole) actor;
			}
		}
		return null;
	}

	/**
	 * 移除指定id的role
	 *
	 * @param id
	 */
	public ActorRole removeRoleByID(long id)
	{
		// if (m_dynamic_actors != null) {
		Actor actor;
		for (int i = 0; i < m_dynamic_actors.size(); i++) {
			actor = (Actor) m_dynamic_actors.elementAt(i);
			if (actor != null && actor instanceof ActorRole && actor.m_gameID == id) {
				m_dynamic_actors.removeElementAt(i);
				return (ActorRole) actor;
			}
		}
		// }
		return null;
	}

	/**
	 * 根据ID获得NPC
	 *
	 * @param id
	 * @return
	 */
	public ActorNPC getNPCByID(long id)
	{
		Actor actor;
		for (int i = 0; i < m_dynamic_actors.size(); i++) {
			actor = (Actor) m_dynamic_actors.elementAt(i);
			// Tools.debugPrintln("查找NPC ID : " + actor.m_gameID + " : " + id);
			if (actor != null && actor instanceof ActorNPC && actor.m_gameID == id) {
				return (ActorNPC) actor;
			}
		}
		return null;
	}

	/**
	 * deactive指定id的NPC
	 *
	 * @param id
	 */
	public ActorNPC deactivateNPCByID(long id)
	{
		Actor actor;
		for (int i = 0; i < m_dynamic_actors.size(); i++) {
			actor = (Actor) m_dynamic_actors.elementAt(i);
			if (actor != null && actor instanceof ActorNPC && actor.m_gameID == id) {
				actor.deactivate();
				return (ActorNPC) actor;
			}
		}
		return null;
	}

	/**
	 * 移除指定id的NPC
	 *
	 * @param id
	 */
	public ActorNPC removeNPCByID(long id)
	{
		Actor actor;
		for (int i = 0; i < m_dynamic_actors.size(); i++) {
			actor = (Actor) m_dynamic_actors.elementAt(i);
			if (actor != null && actor instanceof ActorNPC && actor.m_gameID == id) {
				m_dynamic_actors.removeElementAt(i);
				return (ActorNPC) actor;
			}
		}
		return null;
	}

	public void offLineCheck()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			GameManager.getInstance().m_game_message.sendOffOnline(GameManager.getInstance().m_role.m_gameID,
					GameManager.getInstance().m_userID);
		}
	}

	// /**
	// * 读取场景切换
	// *
	// * @param dis
	// * @throws IOException
	// */
	// private void recvChangeScene(DataInputStream dis) throws IOException
	// {
	// Tools.debugPrintln("anim : " + GameManager.getInstance().m_role.m_anim);
	// GameManager.getInstance().m_stage = dis.readUTF();// 地图ID
	//
	// GameManager.getInstance().m_role.m_posX = dis.readShort();// 坐标 x
	// GameManager.getInstance().m_role.m_posY = dis.readShort();// 坐标 y
	// Tools.debugPrintln("地图ID : " + GameManager.getInstance().m_stage);
	// Tools.debugPrintln("坐标 x : " + GameManager.getInstance().m_role.m_posX);
	// Tools.debugPrintln("坐标 y : " + GameManager.getInstance().m_role.m_posY);
	//
	// byte dir = dis.readByte();// 人物方向
	// Tools.debugPrintln("人物方向 : " + dir);
	// GameManager.getInstance().m_role.setAction(ActorRole.ACTION_STAND *
	// ActorRole.DIRECT_NUM + dir, true);
	//
	// GameManager.getInstance().m_sceneResList.clean();
	// int resNum = dis.readShort();
	// for (int i = 0; i < resNum; i++) {
	// int type = dis.readByte();
	// String url = dis.readUTF();
	// int version = dis.readInt();
	// ResHead resHead = new ResHead(type, url, version);
	// GameManager.getInstance().m_sceneResList.put(resHead);
	// if (type == ObjectAdapter.RESOURCE_TYPE_SCENE) {
	// GameManager.getInstance().m_sceneResHead = resHead;
	// }
	// }
	//
	// GameManager.getInstance().m_sceneResList.merge(GameManager.getInstance().m_roleResList);
	// Tools.debugPrintln("切换场景!");
	// m_isRunning = false;
	// GameManager.getInstance().setGameStatus(GameManager.GS_LOADING);
	// }
	/**
	 * 切换场景确认信息
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvSceneConfirmation(DataInputStream dis) throws IOException
	{
		short con = dis.readShort();
		if (con == 1) {
			setTargetActor(null);
			if (!GameManager.getInstance().m_is_autopath) {
				GameManager.getInstance().m_role.keyAnyStopOther();
			}
			GameManager.getInstance().m_is_autopath = false;
			GameManager.getInstance().m_scene.m_isRunning = false;
			GameManager.getInstance().m_role.closeBattlefieldScore();
			GameManager.getInstance().setGameStatus(GameManager.GS_LOADING);
			Tools.debugPrintln("确认切换场景!");
		}
		else {
			Tools.debugPrintln("切换场景确认信息失败!");
		}
		GameManager.getInstance().m_game_message.unlockNetwork();
	}

	/**
	 * 更新NPC头上状态
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvSceneNPCStatus(DataInputStream dis) throws IOException
	{
		short size = dis.readShort();// 数量
		if (size > 0) {
			m_refresh_thumbnail = false;
			m_thumbnail_list.removeAllElements();
			for (short i = 0; i < size; i++) {
				long npcID = dis.readLong();// id
				short x = dis.readShort();
				short y = dis.readShort();
				byte type = dis.readByte();// 类型
				byte faction = dis.readByte();// 阵营
				int status = dis.readInt();// 状态
				byte function = dis.readByte();
				String headtips = dis.readUTF();
				ActorNPC npc = getNPCByID(npcID);
				if (npc == null) {
					npc = new ActorNPC();
					npc.m_type = type;
					npc.m_posX = x;
					npc.m_posY = y;
				}
				npc.m_head_state = status;
				npc.m_function_icon = function;
				npc.m_head_tips = headtips;
				npc.m_faction = faction;
				if (npc.m_type == AbstractGameActor.ACTOR_TYPE_NPC || npc.m_type == AbstractGameActor.ACTOR_TYPE_GATE) {
					int search_w = m_bg.m_columns * m_bg.m_tileW;
					int search_h = m_bg.m_rows * m_bg.m_tileH;
					int scaling_w = search_w / (THUMBNAIL_SHOW_WIDTH - 6);
					int scaling_h = search_h / (THUMBNAIL_SHOW_HEIGHT - 6);
					if (npc.m_type == AbstractGameActor.ACTOR_TYPE_NPC) {
						if (npc.checkTargetFriend(GameManager.getInstance().m_role)) {
							npc.m_thumbnail_color = Tools.YELLOW;
						}
						else {
							npc.m_thumbnail_color = Tools.RED;
						}
					}
					else if (npc.m_type == AbstractGameActor.ACTOR_TYPE_GATE) {
						npc.m_thumbnail_color = Tools.BLUE;
					}
					npc.m_thumbnail_x = npc.m_posX / scaling_w + 3;
					npc.m_thumbnail_y = npc.m_posY / scaling_h + 3;
					m_thumbnail_list.addElement(npc);
				}
			}
			m_refresh_thumbnail = true;
		}
	}

	/**
	 * 接收角色下线返回信息
	 *
	 * @param m_type
	 * @param body
	 */
	private void recvOffLineMessage(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		String msg = dis.readUTF();
		Tools.debugPrintln(msg);
		if (state != -1) {
			m_isRunning = false;
			GameManager.getInstance().m_user_screen.setNextState(UserScreen.STATE_LOGIN_MAIN);
			GameManager.getInstance().setGameStatus(GameManager.GS_USER);
			GameManager.getInstance().closeConnection();
		}
	}

	// public ArrayList m_pathPoint = new ArrayList();
	/**
	 * 读取升级
	 *
	 * @param
	 */
	public void recvSceneUpgrade(DataInputStream dis) throws IOException
	{
		long id = dis.readLong();
		int level = dis.readInt();
		int maxHP = dis.readInt();
		int maxMP = dis.readInt();
		int sp = dis.readInt();
		int exp = dis.readInt();
		int maxExp = dis.readInt();
		Tools.debugPrintln("角色升级 : " + id + " : " + level + " : " + maxHP + " : " + maxMP + " : " + sp + " : " + exp
				+ " : " + maxExp);
		if (id == m_controlledActor.m_gameID) {
			m_controlledActor.m_lv = level;
			m_controlledActor.m_hpMax = maxHP;
			m_controlledActor.m_mpMax = maxMP;
			((ActorRole) m_controlledActor).m_combatSkillMaxPoint = sp;
			((ActorRole) m_controlledActor).m_exp = exp;
			((ActorRole) m_controlledActor).m_max_exp = maxExp;
			addEffect(2, m_controlledActor.m_posX, m_controlledActor.m_posY);
		}
		else {
			ActorRole role = getRoleByID(id);
			if (role != null) {
				role.m_lv = level;
				role.m_hpMax = maxHP;
				role.m_mpMax = maxMP;
				((ActorRole) role).m_combatSkillMaxPoint = sp;
				((ActorRole) role).m_exp = exp;
				((ActorRole) role).m_max_exp = maxExp;
				addEffect(2, role.m_posX, role.m_posY);
			}
			else {
				Tools.debugPrintln("没有找到升级玩家!");
			}
		}
	}

	/**
	 * 同屏设置NPC动作ID
	 *
	 * @param Long
	 * NPC_id
	 * @param short acitonID
	 * */
	public void recvNPCsetActionID(DataInputStream dis) throws IOException
	{
		try {
			long gameID = dis.readLong();// NPCID
			short acitonID = dis.readShort();// 动作ID
			ActorNPC npc = getNPCByID(gameID);
			if (npc != null) {
				npc.setAction(acitonID, true);
			}
			else {
				Tools.debugPrintln("同屏设置NPC动画错误！没有找到NPC");
			}
		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	/**
	 * 同屏更新返回信息处理
	 *
	 * @param m_type
	 * @param body
	 */
	// public void recvUpdateMessage(DataInputStream dis) throws IOException
	// {
	// // 删除,添加,更新
	// readDeleteActor(dis);// 删除
	// readAddActor(dis);// 添加
	// readUpdate(dis);// 更新
	// }

	// private void readDeleteActor(DataInputStream dis)
	// {
	// try {
	// byte delCount = dis.readByte();// 读取删除角色数量
	// // Tools.debugPrintln("删除角色数量 : " + delCount);
	// for (int i = 0; i < delCount; i++) {
	// long id = dis.readLong();// 读取删除角色ID
	// byte type = dis.readByte();// 读取删除角色类型
	// dis.readByte();// 读取删除角色阵营
	// Tools.debugPrintln("delete actor : " + id + ":删除角色的类型 ：" + type);
	// if (id != m_controlledActor.m_gameID) {
	// Actor actor = removeActorById(type, id);
	// if (actor == m_controlledActor.m_targetActor) {
	// m_controlledActor.m_targetActor = null;
	// setTargetActor(null);
	// }
	// if (actor != null && type == AbstractGameActor.ACTOR_TYPE_ROLE) {//
	// 删除角色，需要删除资源
	// actor.destroy();
	// }
	// }
	// }
	// }
	// catch (Exception e) {
	// Tools.debugPrintln("同屏删除角色ERROR" + e.toString());
	// }
	// }

	private void recvDeleteActor(DataInputStream dis)
	{
		try {
			short delCount = dis.readShort();// 读取删除角色数量
			// Tools.debugPrintln("删除角色数量 : " + delCount);
			for (int i = 0; i < delCount; i++) {
				long id = dis.readLong();// 读取删除角色ID
				byte type = dis.readByte();// 读取删除角色类型
				Tools.debugPrintln("delete actor : " + id + ":删除角色的类型 ：" + type);
				if (id != m_controlledActor.m_gameID) {
					Actor actor = removeActorById(type, id);
					if (actor == m_controlledActor.m_targetActor) {
						m_controlledActor.m_targetActor = null;
						setTargetActor(null);
					}
					if (actor != null && type == AbstractGameActor.ACTOR_TYPE_ROLE) {// 删除角色，需要删除资源
						actor.destroy();
					}
				}
			}
		}
		catch (Exception e) {
			Tools.debugPrintln("同屏删除角色ERROR" + e.toString());
		}
	}

	// private void readAddActor(DataInputStream dis)
	// {
	// try {
	// byte addCount = dis.readByte();// 读取添加角色数量
	// if (addCount > 0) {
	// // Tools.debugPrintln("同屏添加角色数量 : " + addCount);
	// }
	// for (int i = 0; i < addCount; i++) {
	// long gameID = dis.readLong();// 读取添加ID
	// // Tools.debugPrintln("gameID：" + gameID);
	// byte type = dis.readByte();// 读取类型
	// // Tools.debugPrintln("type：" + type);
	// byte faction = dis.readByte();// 读取阵营
	// // Tools.debugPrintln("faction：" + faction);
	// byte[] vocation = new byte[dis.readShort()];// 读取职业，npc为0
	// for (int j = 0; j < vocation.length; j++) {
	// vocation[j] = dis.readByte();
	// // Tools.debugPrintln("vocation["+j+"]=" + vocation[j]);
	// }
	// byte sex = dis.readByte();// 读取性别
	// // Tools.debugPrintln("sex ：" + sex);
	// byte race = dis.readByte();// 读取种族
	// // Tools.debugPrintln("race ：" + race);
	// String name = dis.readUTF();// 读取昵称
	// // Tools.debugPrintln("name：" + name);
	// short level = dis.readShort();// 读取等级
	// // Tools.debugPrintln("level：" + level);
	// byte status = dis.readByte();// 读取状态
	// // Tools.debugPrintln("status：" + status);
	// int action = dis.readInt();// 读取行为
	// // Tools.debugPrintln("action：" + action);
	// int hp = dis.readInt();// 读取当前生命值
	// // Tools.debugPrintln("hp：" + hp);
	// int hpMax = dis.readInt();// 读取最大生命值
	// // Tools.debugPrintln("hpMax：" + hpMax);
	// int mp = dis.readInt();// 读取当前魔法值
	// // Tools.debugPrintln("mp：" + mp);
	// int mpMax = dis.readInt();// 读取最大魔法值
	// // Tools.debugPrintln("mpMax：" + mpMax);
	// byte animCount = dis.readByte();// 资源个数
	// // Tools.debugPrintln("animCount：" + animCount);
	// byte zq_type = 0;
	//
	// String[] resUrl = new String[animCount];
	// String temp;
	// for (int j = 0; j < animCount; j++) {
	// temp = dis.readUTF();
	// if (temp.length() < 2) {
	// temp = null;
	// }
	// resUrl[j] = temp;
	// if (j == 0 && type == AbstractGameActor.ACTOR_TYPE_ROLE) {
	// zq_type = dis.readByte();// 坐骑类型
	// // Tools.debugPrintln("坐寄类型 zq_type="+zq_type);
	// }
	// // Tools.debugPrintln("添加动画URL resUrl["+j+"]="+resUrl[j]);
	// }
	// int speed = dis.readInt();// 速度
	// // Tools.debugPrintln("速度="+speed);
	// short posX = dis.readShort();// 坐标X
	// short posY = dis.readShort();// 坐标Y
	// short actionId = dis.readShort();// 动作ID
	//
	// Tools.debugPrintln("add actor : " + name + " : " + gameID + " : " +
	// status);
	// if (gameID == m_controlledActor.m_gameID) {// 玩家控制角色
	// // Tools.debugPrintln("目标位玩家自己");
	// m_controlledActor.m_hp = hp;
	// m_controlledActor.m_hpMax = hpMax;
	// m_controlledActor.m_mp = mp;
	// m_controlledActor.m_mpMax = mpMax;
	// }
	// else if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {// 其他角色
	// // Tools.debugPrintln("添加角色ID : " + gameID);
	// ActorRole role = getRoleByID(gameID);
	// if (role != null) {
	// Tools.debugPrintln("添加角色已存在  gameID:" + gameID + "  name:" + name);
	// continue;
	// }
	// role = new ActorRole();
	// role.m_gameID = gameID;
	// role.m_type = type;
	// role.m_faction = faction;
	// role.m_vocation = new byte[vocation.length];
	// System.arraycopy(vocation, 0, role.m_vocation, 0, vocation.length);
	// role.m_race = race;
	// role.m_sex = sex;
	// role.m_name = name;
	// role.m_lv = level;
	// role.m_status = status;
	// role.m_action = action;
	// role.m_hp = hp;
	// role.m_hpMax = hpMax;
	// role.m_mp = mp;
	// role.m_mpMax = mpMax;
	// role.m_anims = new Animation[animCount];
	// role.m_refsResHead = new ResHead[animCount];
	// role.m_velocity = speed / GameManager.FRAME_PER_SECOND <<
	// Actor.ACTOR_FRACTION_BIT;
	// boolean flag = SerializeableImage.isFreeMemory();
	// Animation anim;
	// for (int j = 0; j < animCount; j++) {
	// switch (j) {
	// case 0:// 坐骑
	// case 2:// 武器
	// if (resUrl[j] != null) {
	// role.m_refsResHead[j] = new ResHead();
	// role.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;//
	// 读取角色动画资源类型
	// role.m_refsResHead[j].m_version = 1;// 读取角色动画资源版本
	// role.m_refsResHead[j].m_url =
	// ObjectAdapter.DIR_ANIM.concat(resUrl[j]).concat(
	// ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
	// if (!flag) {// 如果内存足够
	// anim = null;
	// anim = (Animation) (ResourceManager.getInstance().loadResource(
	// GameManager.getInstance().m_resource_scene, role.m_refsResHead[j]));
	// if (anim != null && anim.m_loadFinished) {
	// role.m_anims[j] = anim;
	// }
	// }
	// }
	// break;
	// case 1:// 角色
	// if (resUrl[j] != null) {
	// role.m_refsResHead[j] = new ResHead();
	// role.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;//
	// 读取角色动画资源类型
	// role.m_refsResHead[j].m_version = 1;// 读取角色动画资源版本
	// String _url = null;
	// _url = GameManager.getInstance().getClothHead(role.m_sex, role.m_race);
	// role.m_refsResHead[j].m_url =
	// ObjectAdapter.DIR_ANIM.concat(_url).concat(resUrl[j])
	// .concat(
	// ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
	// _url = null;
	// if (!flag) {// 如果内存足够
	// anim = null;
	// anim = (Animation) (ResourceManager.getInstance().loadResource(
	// GameManager.getInstance().m_resource_scene, role.m_refsResHead[j]));
	// if (anim != null && anim.m_loadFinished) {
	// role.m_anims[j] = anim;
	// }
	// else {
	// role.m_anims[j] = GameManager.getInstance().m_shadowAnimation;
	// }
	// }
	// else {
	// role.m_anims[j] = GameManager.getInstance().m_shadowAnimation;
	// }
	// }
	// break;
	// }
	// }
	//
	// role.m_ride = new ActorItemRide();// 角色当前坐骑引用
	// switch (zq_type) {
	// case ActorItemRide.TYPE_SKY:
	// case ActorItemRide.TYPE_GROUND:
	// case ActorItemRide.TYPE_SWARD:
	// role.m_isride = true;
	// role.m_ride.m_speed = speed;
	// role.m_ride.m_rideType = zq_type;
	// break;
	// default:
	// role.m_isride = false;
	// role.m_ride.m_speed = 0;
	// if (zq_type == -1) {
	// zq_type = 0;
	// }
	// role.m_ride.m_rideType = zq_type;
	// break;
	// }
	// // Tools.debugPrintln("role.m_ride.m_rideType="+role.m_ride.m_rideType);
	// if (role.m_anims[1] != null) {
	// role.m_anim = role.m_anims[1];
	// }
	// else {
	// Tools.debugPrintln("同屏载入其他角色动作出错！role.m_anim[1]=null");
	// }
	//
	// role.m_posX = posX;
	// role.m_posY = posY;
	// if (role.m_status == ActorRole.ACTOR_STATUS_ROLE_DEAD) {
	// role.setAction(ActorRole.ACTION_DEAD1 * ActorRole.DIRECT_NUM, 0, 0,
	// false, true);
	// role.setFrame(role.m_anim.m_actions[ActorRole.ACTION_DEAD1 *
	// ActorRole.DIRECT_NUM].length - 1);
	// }
	// else {
	// role.setAction(actionId, true);
	// }
	// addDynamicActor(role);
	// }
	// else if (type == AbstractGameActor.ACTOR_TYPE_ITEM) { // 掉落道具
	// // Tools.debugPrintln("同屏 道具 添加NPCID : " + gameID);
	// ActorNPC npc = getNPCByID(gameID);
	// boolean exist = true;
	// if (npc == null) {
	// exist = false;
	// npc = new ActorNPC();
	// }
	//
	// npc.m_faction = faction;
	// npc.m_type = type;
	// npc.m_gameID = gameID;
	// npc.m_name = name;
	// npc.m_lv = level;
	// npc.m_status = status;
	// npc.m_action = action;
	// npc.m_hp = hp;
	// npc.m_hpMax = hpMax;
	// npc.m_mp = mp;
	// npc.m_mpMax = mpMax;
	// npc.m_anims = new Animation[animCount];
	// npc.m_refsResHead = new ResHead[animCount];
	// for (int j = 0; j < animCount; j++) {
	// npc.m_refsResHead[j] = new ResHead();
	// npc.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;//
	// 读取动画资源类型
	// npc.m_refsResHead[j].m_url = ObjectAdapter.DIR_ANIM.concat(
	// resUrl[j]).concat(ObjectAdapter.EXTENSION_ANIM);// 读取动画资源URL
	// npc.m_refsResHead[j].m_version = 1;// 读取动画资源版本
	// npc.m_anims[j] = (Animation) (ResourceManager.getInstance().loadResource(
	// GameManager.getInstance().m_resource_scene,
	// npc.m_refsResHead[j]));
	// }
	// npc.m_anim = npc.m_anims[0];
	// npc.m_posX = posX;
	// npc.m_posY = posY;
	// npc.setAction(actionId, true);
	// npc.activate();
	// // 最后才添加进动态Actor列表，尽量避免线程冲突
	// if (!exist) {
	// addDynamicActor(npc);
	// }
	// // 处理道具拾取人
	// if (npc.m_type == AbstractGameActor.ACTOR_TYPE_ITEM) {
	// int num = dis.readByte();
	// // num == -1时 m_relatedActorsID 为空，所有人可以拾取
	// if (num >= 0) {
	// npc.m_relatedActorsID = new long[num];
	// for (int j = 0; j < num; j++) {
	// npc.m_relatedActorsID[j] = dis.readLong();
	// }
	// }
	// }
	// }
	// else { // npc
	// Tools.debugPrintln("同屏添加NPCID : " + gameID + "");
	// ActorNPC npc = getNPCByID(gameID);
	// boolean exist = true;
	// ResHead head = new ResHead();
	// head.m_type = ObjectAdapter.RESOURCE_TYPE_NPC;
	// head.m_url = ObjectAdapter.DIR_AC.concat(resUrl[0]).concat(
	// ObjectAdapter.EXTENSION_AC);// 读取角色动画资源URL
	// head.m_version = 1;
	// if (npc == null) {
	// exist = false;
	// // npc所对应的ac文件名
	// Tools.debugPrintln("NPC 添加URL=" + head.m_url + ";npc actionID=" +
	// actionId);
	// ActorNPC model = (ActorNPC) ResourceManager.getInstance().loadResource(
	// GameManager.getInstance().m_resource_scene, head);
	// if (model == null) {
	// npc = new ActorNPC();
	// npc.m_resHead = head;
	// }
	// else {
	// npc = (ActorNPC) model.clone();
	// }
	// }
	//
	// npc.m_faction = faction;
	// npc.m_type = type;
	// npc.m_gameID = gameID;
	// npc.m_name = name;
	// npc.m_lv = level;
	// npc.m_status = status;
	// npc.m_action = action;
	// npc.m_hp = hp;
	// npc.m_hpMax = hpMax;
	// npc.m_mp = mp;
	// npc.m_mpMax = mpMax;
	//
	// npc.m_anim = npc.m_anims[0];
	// npc.m_posX = posX;
	// npc.m_posY = posY;
	// if (npc.m_status == ActorRole.ACTOR_STATUS_ROLE_DEAD) {
	// npc.setAction(ActorNPC.ACTION_DEAD1 * ActorNPC.DIRECT_NUM, 0, 0, false,
	// true);
	// npc.setFrame(npc.m_anim.m_actions[ActorNPC.ACTION_DEAD1 *
	// ActorRole.DIRECT_NUM].length - 1);
	// }
	// else {
	// npc.setAction(actionId, true);
	// }
	// npc.activate();
	// // 最后才添加进动态Actor列表，尽量避免线程冲突
	// if (!exist) {
	// addDynamicActor(npc);
	// }
	// }
	// }
	// }
	// catch (Exception e) {
	// Tools.debug(e);
	// }
	//
	// }

	private void recvAddActor(DataInputStream dis)
	{
		try {
			short addCount = dis.readShort();// 读取添加角色数量
			for (int i = 0; i < addCount; i++) {
				long gameID = dis.readLong();// 读取添加ID
				byte type = dis.readByte();// 读取类型
				byte faction = dis.readByte();// 读取阵营
				byte[] vocation = new byte[dis.readByte()];// 读取职业，npc为0
				for (int j = 0; j < vocation.length; j++) {
					vocation[j] = dis.readByte();
				}
				byte vip_lv = 0;
				if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {
					vip_lv = dis.readByte();
				}
				byte sex = dis.readByte();// 读取性别
				byte race = dis.readByte();// 读取种族
				String name = dis.readUTF();// 读取昵称
				short level = dis.readShort();// 读取等级
				byte status = dis.readByte();// 读取状态
				int action = dis.readInt();// 读取行为
				int hp = dis.readInt();// 读取当前生命值
				int hpMax = dis.readInt();// 读取最大生命值
				int mp = dis.readInt();// 读取当前魔法值
				int mpMax = dis.readInt();// 读取最大魔法值
				byte animCount = dis.readByte();// 资源个数

				String[] resUrl = new String[animCount];
				String temp;
				for (int j = 0; j < animCount; j++) {
					temp = dis.readUTF();
					if (temp.length() < 2) {
						temp = null;
					}
					resUrl[j] = temp;
				}
				byte zq_type = 0;
				byte appellation_color = 0;
				String appellation = null;
				String family = null;
				if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {
					family = dis.readUTF();
					appellation_color = dis.readByte();
					appellation = dis.readUTF();
					zq_type = dis.readByte();
				}
				int speed = dis.readShort();// 速度
				short posX = dis.readShort();// 坐标X
				short posY = dis.readShort();// 坐标Y
				short actionId = dis.readShort();// 动作ID

				Tools.debugPrintln("add actor : " + name + " : " + gameID + " : " + status + " : " + family);
				if (gameID == m_controlledActor.m_gameID) {// 玩家控制角色
					// Tools.debugPrintln("目标位玩家自己");
					m_controlledActor.m_hp = hp;
					m_controlledActor.m_hpMax = hpMax;
					m_controlledActor.m_mp = mp;
					m_controlledActor.m_mpMax = mpMax;
					GameManager.getInstance().m_role.m_vip_lv = vip_lv;
					GameManager.getInstance().m_role.m_appellation = appellation;
					GameManager.getInstance().m_role.m_family_name = family;
					GameManager.getInstance().m_role.m_appellation_color = appellation_color;
				}
				else if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {// 其他角色
					// Tools.debugPrintln("添加角色ID : " + gameID);
					ActorRole role = getRoleByID(gameID);
					if (role != null) {
						Tools.debugPrintln("添加角色已存在  gameID:" + gameID + "  name:" + name);
						continue;
					}
					role = new ActorRole();
					role.m_gameID = gameID;
					role.m_type = type;
					role.m_faction = faction;
					role.m_vip_lv = vip_lv;
					role.m_family_name = family;
					role.m_vocation = new byte[vocation.length];
					System.arraycopy(vocation, 0, role.m_vocation, 0, vocation.length);
					role.m_race = race;
					role.m_sex = sex;
					role.m_name = name;
					role.m_lv = level;
					role.m_status = status;
					role.m_action = action;
					role.m_hp = hp;
					role.m_hpMax = hpMax;
					role.m_mp = mp;
					role.m_mpMax = mpMax;
					role.m_appellation_color = appellation_color;
					role.m_appellation = appellation;
					role.m_anims = new Animation[animCount];
					role.m_refsResHead = new ResHead[animCount];
					role.m_velocity = speed / GameManager.FRAME_PER_SECOND << Actor.ACTOR_FRACTION_BIT;
					boolean flag = SerializeableImage.isFreeMemory();
					Animation anim;
					for (int j = 0; j < animCount; j++) {
						switch (j) {
							case 0:// 坐骑
							case 2:// 武器
								if (resUrl[j] != null) {
									role.m_refsResHead[j] = new ResHead();
									role.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;// 读取角色动画资源类型
									role.m_refsResHead[j].m_version = 1;// 读取角色动画资源版本
									role.m_refsResHead[j].m_url = ObjectAdapter.DIR_ANIM.concat(resUrl[j]).concat(
											ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
									if (!flag) {// 如果内存足够
										anim = null;
										anim = (Animation) (ResourceManager.getInstance().loadResource(GameManager
												.getInstance().m_resource_scene, role.m_refsResHead[j]));
										if (anim != null && anim.m_loadFinished) {
											role.m_anims[j] = anim;
										}
									}
								}
								break;
							case 1:// 角色
								if (resUrl[j] != null) {
									role.m_refsResHead[j] = new ResHead();
									role.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;// 读取角色动画资源类型
									role.m_refsResHead[j].m_version = 1;// 读取角色动画资源版本
									String _url = null;
									_url = GameManager.getInstance().getClothHead(role.m_sex, role.m_race);
									role.m_refsResHead[j].m_url = ObjectAdapter.DIR_ANIM.concat(_url).concat(resUrl[j])
											.concat(ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
									_url = null;
									if (!flag) {// 如果内存足够
										anim = null;
										anim = (Animation) (ResourceManager.getInstance().loadResource(GameManager
												.getInstance().m_resource_scene, role.m_refsResHead[j]));
										if (anim != null && anim.m_loadFinished) {
											role.m_anims[j] = anim;
										}
										else {
											role.m_anims[j] = GameManager.getInstance().m_shadowAnimation;
										}
									}
									else {
										role.m_anims[j] = GameManager.getInstance().m_shadowAnimation;
									}
								}
								break;
						}
					}

					role.m_ride = new ActorItemRide();// 角色当前坐骑引用
					switch (zq_type) {
						case ActorItemRide.TYPE_SKY:
						case ActorItemRide.TYPE_GROUND:
						case ActorItemRide.TYPE_SWARD:
							role.m_isride = true;
							role.m_ride.m_speed = speed;
							role.m_ride.m_rideType = zq_type;
							break;
						default:
							role.m_isride = false;
							role.m_ride = null;
							break;
					}
					// Tools.debugPrintln("role.m_ride.m_rideType="+role.m_ride.m_rideType);
					if (role.m_anims[1] != null) {
						role.m_anim = role.m_anims[1];
					}
					else {
						Tools.debugPrintln("同屏载入其他角色动作出错！role.m_anim[1]=null");
					}

					role.m_posX = posX;
					role.m_posY = posY;
					if (role.m_status == ActorRole.ACTOR_STATUS_ROLE_DEAD) {
						role.setAction(ActorRole.ACTION_DEAD1 * ActorRole.DIRECT_NUM, 0, 0, false, true);
						role.setFrame(role.m_anim.m_actions[ActorRole.ACTION_DEAD1 * ActorRole.DIRECT_NUM].length - 1);
					}
					else {
						role.setAction(actionId, true);
					}
					addDynamicActor(role);
				}
				else if (type == AbstractGameActor.ACTOR_TYPE_FAZHEN) {
					// Tools.debugPrintln("同屏 道具 添加NPCID : " + gameID);
					ActorNPC npc = getNPCByID(gameID);
					boolean exist = true;
					if (npc == null) {
						exist = false;
						npc = new ActorNPC();
					}

					npc.m_faction = faction;
					npc.m_type = type;
					npc.m_gameID = gameID;
					npc.m_name = name;
					npc.m_lv = level;
					npc.m_status = status;
					npc.m_action = action;
					npc.m_hp = hp;
					npc.m_hpMax = hpMax;
					npc.m_mp = mp;
					npc.m_mpMax = mpMax;
					npc.m_anims = new Animation[animCount];
					npc.m_refsResHead = new ResHead[animCount];
					for (int j = 0; j < animCount; j++) {
						npc.m_refsResHead[j] = new ResHead();
						npc.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;// 读取动画资源类型
						npc.m_refsResHead[j].m_url = ObjectAdapter.DIR_ANIM.concat(resUrl[j]).concat(
								ObjectAdapter.EXTENSION_ANIM);// 读取动画资源URL
						npc.m_refsResHead[j].m_version = 1;// 读取动画资源版本
						npc.m_anims[j] = (Animation) (ResourceManager.getInstance().loadResource(GameManager
								.getInstance().m_resource_scene, npc.m_refsResHead[j]));
					}
					npc.m_anim = npc.m_anims[0];
					npc.m_posX = posX;
					npc.m_posY = posY;
					npc.setAction(actionId, true);
					npc.activate();
					// 最后才添加进动态Actor列表，尽量避免线程冲突
					if (!exist) {
						addDynamicActor(npc);
					}
				}
				else if (type == AbstractGameActor.ACTOR_TYPE_ITEM) { // 掉落道具
					// Tools.debugPrintln("同屏 道具 添加NPCID : " + gameID);
					ActorNPC npc = getNPCByID(gameID);
					boolean exist = true;
					if (npc == null) {
						exist = false;
						npc = new ActorNPC();
					}

					npc.m_faction = faction;
					npc.m_type = type;
					npc.m_gameID = gameID;
					npc.m_name = name;
					npc.m_lv = level;
					npc.m_status = status;
					npc.m_action = action;
					npc.m_hp = hp;
					npc.m_hpMax = hpMax;
					npc.m_mp = mp;
					npc.m_mpMax = mpMax;
					npc.m_anims = new Animation[animCount];
					npc.m_refsResHead = new ResHead[animCount];
					for (int j = 0; j < animCount; j++) {
						npc.m_refsResHead[j] = new ResHead();
						npc.m_refsResHead[j].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;// 读取动画资源类型
						npc.m_refsResHead[j].m_url = ObjectAdapter.DIR_ANIM.concat(resUrl[j]).concat(
								ObjectAdapter.EXTENSION_ANIM);// 读取动画资源URL
						npc.m_refsResHead[j].m_version = 1;// 读取动画资源版本
						npc.m_anims[j] = (Animation) (ResourceManager.getInstance().loadResource(GameManager
								.getInstance().m_resource_scene, npc.m_refsResHead[j]));
					}
					npc.m_anim = npc.m_anims[0];
					npc.m_posX = posX;
					npc.m_posY = posY;
					npc.setAction(actionId, true);
					npc.activate();
					// 最后才添加进动态Actor列表，尽量避免线程冲突
					if (!exist) {
						addDynamicActor(npc);
					}
					// 处理道具拾取人
					if (npc.m_type == AbstractGameActor.ACTOR_TYPE_ITEM) {
						int num = dis.readByte();
						// num == -1时 m_relatedActorsID 为空，所有人可以拾取
						if (num >= 0) {
							npc.m_relatedActorsID = new long[num];
							for (int j = 0; j < num; j++) {
								npc.m_relatedActorsID[j] = dis.readLong();
							}
						}
					}
				}
				else { // npc
						// Tools.debugPrintln("同屏添加NPCID : " + gameID+"");
					ActorNPC npc = getNPCByID(gameID);
					boolean exist = true;
					ResHead head = new ResHead();
					head.m_type = ObjectAdapter.RESOURCE_TYPE_NPC;
					head.m_url = ObjectAdapter.DIR_AC.concat(resUrl[0]).concat(ObjectAdapter.EXTENSION_AC);// 读取角色动画资源URL
					head.m_version = 1;
					if (npc == null) {
						exist = false;
						// npc所对应的ac文件名
						// Tools.debugPrintln("NPC 添加URL="+head.m_url+";npc actionID="+actionId);
						ActorNPC model = (ActorNPC) ResourceManager.getInstance().loadResource(
								GameManager.getInstance().m_resource_scene, head);
						if (model == null) {
							Tools.debugPrintln("场景文件中缺失NPC数据： NPC url = " + head.m_url);
							continue;
						}
						else {
							npc = (ActorNPC) model.clone();
						}
					}

					npc.m_faction = faction;
					npc.m_type = type;
					npc.m_gameID = gameID;
					npc.m_name = name;
					npc.m_lv = level;
					npc.m_status = status;
					npc.m_action = action;
					npc.m_hp = hp;
					npc.m_hpMax = hpMax;
					npc.m_mp = mp;
					npc.m_mpMax = mpMax;
//                    if(npc.m_name.equals("阎罗王")){
//                    	Tools.debugPrintln("阎罗王 action="+npc.m_action);
//                    }
					npc.m_anim = npc.m_anims[0];
					npc.m_posX = posX;
					npc.m_posY = posY;
					if (npc.m_status == ActorRole.ACTOR_STATUS_ROLE_DEAD) {
						npc.setAction(ActorNPC.ACTION_DEAD1 * ActorNPC.DIRECT_NUM, 0, 0, false, true);
						npc.setFrame(npc.m_anim.m_actions[ActorNPC.ACTION_DEAD1 * ActorRole.DIRECT_NUM].length - 1);
					}
					else {
						npc.setAction(actionId, true);
					}
					npc.activate();
					// 最后才添加进动态Actor列表，尽量避免线程冲突
					if (!exist) {
						addDynamicActor(npc);
					}
				}
			}
		}
		catch (Exception e) {
			Tools.debug(e);
		}

	}

	// private void readUpdate(DataInputStream dis)
	// {
	// try {
	// byte actorCount = dis.readByte();// 读取更新角色的数量
	// // Tools.debugPrintln("同屏更新角色数量="+actorCount);
	// for (int i = 0; i < actorCount; i++) {
	// long id = dis.readLong();// 读取更新ID
	// // Tools.debugPrintln("id="+id);
	// byte type = dis.readByte();// 读取类型
	// // Tools.debugPrintln("type="+type);
	// byte faction = dis.readByte();// 读取阵营
	// // Tools.debugPrintln("faction="+faction);
	// byte[] vocation = new byte[dis.readShort()];// 读取职业，npc为0
	// // Tools.debugPrintln("vocation 长度="+vocation.length);
	// for (int j = 0; j < vocation.length; j++) {
	// vocation[j] = dis.readByte();
	// // Tools.debugPrintln("vocation["+j+"]=" + vocation[j]);
	// }
	// String name = dis.readUTF();// 读取昵称
	// // Tools.debugPrintln("name="+name);
	// short level = dis.readShort();// 读取等级
	// // Tools.debugPrintln("level="+level);
	// byte status = dis.readByte();// 读取状态
	// // Tools.debugPrintln("status="+status);
	// int action = dis.readInt();// 读取行为
	// // Tools.debugPrintln("action="+action);
	// int hp = dis.readInt();// 读取当前生命值
	// // Tools.debugPrintln("hp="+hp);
	// int hpMax = dis.readInt();// 读取最大生命值
	// // Tools.debugPrintln("hpMax="+hpMax);
	// int mp = dis.readInt();// 读取当前魔法值
	// // Tools.debugPrintln("mp="+mp);
	// int mpMax = dis.readInt();// 读取最大魔法值
	// // Tools.debugPrintln("mpMax="+mpMax);
	// byte animCount = dis.readByte();// 读资源个数
	// // Tools.debugPrintln("animCount="+animCount);
	// String[] resUrl = new String[animCount];
	// String temp;
	// byte zq_type = 0;
	// for (int j = 0; j < animCount; j++) {
	// temp = dis.readUTF();
	// if (temp.length() < 2) {
	// temp = null;
	// }
	// resUrl[j] = temp;// 动画URL
	// if (j == 0 && type == AbstractGameActor.ACTOR_TYPE_ROLE) {
	// zq_type = dis.readByte();// 坐骑类型
	// }
	// //
	// Tools.debugPrintln("resUrl["+j+"]="+resUrl[j]+";坐寄类型 zq_type="+zq_type);
	// }
	//
	// int speed = dis.readInt();// 角色速度
	// // Tools.debugPrintln("速度="+speed);
	// int pointNum = dis.readByte();
	// // Tools.debugPrintln("pointNum="+pointNum);
	// short[][] points = new short[pointNum][2];
	// for (int ii = 0; ii < pointNum; ii++) {
	// points[ii][0] = dis.readShort();
	// // Tools.debugPrintln("points["+ii+"][0]="+points[ii][0]);
	// points[ii][1] = dis.readShort();
	// // Tools.debugPrintln("points["+ii+"][1]="+points[ii][1]);
	// }
	//
	// if (id == m_controlledActor.m_gameID) {
	// m_controlledActor.m_hp = hp;
	// m_controlledActor.m_hpMax = hpMax;
	// m_controlledActor.m_mp = mp;
	// m_controlledActor.m_mpMax = mpMax;
	// }
	// else if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {// 更新动态角色
	// ActorRole role = getRoleByID(id);
	// if (role == null) {
	// Tools.debugPrintln("更新角色失败 ,无法找到该角色--id:" + id + "  name:" + name);
	// continue;
	// }
	// role.m_faction = faction;
	// role.m_vocation = new byte[vocation.length];
	// System.arraycopy(vocation, 0, role.m_vocation, 0, vocation.length);
	// role.m_type = type;
	// role.m_name = name;
	// role.m_lv = level;
	// role.m_status = status;
	// role.m_action = action;
	// role.m_hp = hp;
	// role.m_hpMax = hpMax;
	// role.m_mp = mp;
	// role.m_mpMax = mpMax;
	//
	// if (points.length > 0) {
	// role.addFlex(points[points.length - 1]);
	// }
	//
	// // Tools.debugPrintln("同屏更新当前循环数="+i+";当前更新角色名字="+name);
	// String url = null;
	// boolean urlok = false;
	// for (int k = 0; k < animCount; k++) {
	// // Tools.debugPrintln("同屏更新  resUrl[" + k + "]=" + resUrl[k]);
	// urlok = (resUrl[k] != null && resUrl[k].length() > 1);
	// switch (k) {
	// case 0:// 坐骑
	// case 2:// 武器
	// if (urlok) {// URL 不NULL
	// url =
	// ObjectAdapter.DIR_ANIM.concat(resUrl[k]).concat(ObjectAdapter.EXTENSION_ANIM);//
	// 读取角色动画资源URL
	// if (role.m_refsResHead[k] == null) {// 如果当前资源列表为空
	// role.m_refsResHead[k] = new ResHead();
	// role.m_refsResHead[k].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;//
	// 读取角色动画资源类型
	// role.m_refsResHead[k].m_version = 1;// 读取角色动画资源版本
	// role.m_refsResHead[k].m_url = url;
	// role.m_anims[k] = null;
	// }
	// else {// 当前资源不为空
	// if (url.length() > 1 && !role.m_refsResHead[k].m_url.equals(url)) {
	// role.m_refsResHead[k].m_url = url;
	// }
	// }
	// }
	// else {// URL NULL
	// if (role.m_refsResHead[k] != null) {// 如果当前资源列表不空
	// role.animsDestroy(role.m_anims[k], role.m_refsResHead[k]);
	// role.m_anims[k] = null;
	// role.m_refsResHead[k] = null;
	// }
	// }
	// break;
	// case 1:// 角色
	// if (urlok) {
	// url = GameManager.getInstance().getClothHead(role.m_sex, role.m_race);
	// url = ObjectAdapter.DIR_ANIM.concat(url).concat(resUrl[k]).concat(
	// ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
	// if (!role.m_refsResHead[k].m_url.equals(url)) {// 是不同URL
	// ResHead head = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, url, 1);
	// role.m_refsResHead[k] = head;
	// }
	// }
	// break;
	// }
	// }
	//
	// if (role.m_ride != null) {
	// switch (zq_type) {// 更新坐骑类型
	// case ActorItemRide.TYPE_SKY:
	// case ActorItemRide.TYPE_GROUND:
	// case ActorItemRide.TYPE_SWARD:
	// role.m_isride = true;
	// role.m_ride.m_speed = speed;
	// role.m_ride.m_rideType = zq_type;
	// break;
	// default:
	// role.m_isride = false;
	// role.m_ride.m_speed = speed;
	// role.m_ride.m_rideType = zq_type;
	// break;
	// }
	// role.m_velocity = speed / GameManager.FRAME_PER_SECOND <<
	// Actor.ACTOR_FRACTION_BIT;
	// }
	// if (role.m_anims != null && role.m_anims[1] != null) {
	// role.m_anim = role.m_anims[1];
	// }
	// else {
	// Tools.debugPrintln("同屏更新时动作出错 role.m_anims[1]=null");
	// Tools.debugPrintln("anim name : " + role.m_refsResHead[1]);
	// }
	// }
	// else {
	// ActorNPC npc = getNPCByID(id);
	// if (npc == null) {
	// if (type == AbstractGameActor.ACTOR_TYPE_ITEM) {
	// int num = dis.readByte();
	// if (num >= 0) {
	// for (int j = 0; j < num; j++) {
	// dis.readLong();
	// }
	// }
	// }
	// // Tools.debugPrintln("更新NPC失败 ,无法找到该NPC--id:" + id + "  name:" + name);
	// continue;
	// }
	// npc.m_faction = faction;
	// npc.m_type = type;
	// npc.m_name = name;
	// npc.m_lv = level;
	// npc.m_status = status;
	// npc.m_action = action;
	// npc.m_hp = hp;
	// npc.m_hpMax = hpMax;
	// npc.m_mp = mp;
	// npc.m_mpMax = mpMax;
	//
	// if (points.length > 0) {
	// npc.addFlex(points[points.length - 1]);
	// }
	//
	// // 处理道具拾取人
	// if (npc.m_type == AbstractGameActor.ACTOR_TYPE_ITEM) {
	// int num = dis.readByte();
	// // num == -1时 m_relatedActorsID 为空，所有人可以拾取
	// if (num >= 0) {
	// // Tools.debugPrintln("num="+num);
	// npc.m_relatedActorsID = new long[num];
	// for (int j = 0; j < num; j++) {
	// npc.m_relatedActorsID[j] = dis.readLong();
	// //
	// Tools.debugPrintln("npc.m_relatedActorsID["+j+"]="+npc.m_relatedActorsID[j]);
	// }
	// }
	// }
	// }
	// }
	// }
	// catch (Exception e) {
	// Tools.debug(e);
	// }
	// }
	private ArrayList m_update_deficiency = new ArrayList();

	private void recvUpdateActorData(DataInputStream dis)
	{
		try {
			short actorCount = dis.readShort();// 读取更新角色的数量
			if (m_update_deficiency == null) {
				m_update_deficiency = new ArrayList();
			}
			m_update_deficiency.removeAllElements();
			for (int i = 0; i < actorCount; i++) {
				long id = dis.readLong();// 读取更新ID
				byte type = dis.readByte();// 读取类型
				int hp = dis.readInt();// 读取当前生命值
				int hpMax = dis.readInt();// 读取最大生命值
				int mp = dis.readInt();// 读取当前魔法值
				int mpMax = dis.readInt();// 读取最大魔法值
				int pointNum = dis.readByte();
				short[][] points = new short[pointNum][2];
				for (int ii = 0; ii < pointNum; ii++) {
					points[ii][0] = dis.readShort();
					points[ii][1] = dis.readShort();
				}

				if (id == m_controlledActor.m_gameID) {
					m_controlledActor.m_hp = hp;
					m_controlledActor.m_hpMax = hpMax;
					m_controlledActor.m_mp = mp;
					m_controlledActor.m_mpMax = mpMax;
				}
				else if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {// 更新动态角色
					ActorRole role = getRoleByID(id);
					if (role == null) {
						Tools.debugPrintln("更新角色基础数据失败 ,无法找到该角色--id:" + id);
						ActorRole temp = new ActorRole();
						temp.m_gameID = id;
						temp.m_type = type;
						m_update_deficiency.addElement(temp);
						continue;
					}
					role.m_type = type;
					role.m_hp = hp;
					role.m_hpMax = hpMax;
					role.m_mp = mp;
					role.m_mpMax = mpMax;

					if (points.length > 0) {
						role.addFlex(points[points.length - 1]);
					}
				}
				else {
					ActorNPC npc = getNPCByID(id);
					if (npc == null) {
						Tools.debugPrintln("更新NPC基础数据失败 ,无法找到该NPC--id:" + id);
						ActorNPC temp = new ActorNPC();
						temp.m_gameID = id;
						temp.m_type = type;
						m_update_deficiency.addElement(temp);
						continue;
					}
					npc.m_type = type;
					npc.m_hp = hp;
					npc.m_hpMax = hpMax;
					npc.m_mp = mp;
					npc.m_mpMax = mpMax;

					if (points.length > 0) {
						npc.addFlex(points[points.length - 1]);
					}
				}
			}
			if (m_update_deficiency.size() > 0) {
				GameManager.getInstance().m_game_message.sendSceneUpdateDeficiency(m_update_deficiency);
			}
		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	private void recvUpdateActorFigure(DataInputStream dis)
	{
		try {
			short actorCount = dis.readShort();// 读取更新角色的数量
			for (int i = 0; i < actorCount; i++) {
				long id = dis.readLong();// 读取更新ID
				byte type = dis.readByte();// 读取类型
				byte animCount = dis.readByte();// 读资源个数
				String[] resUrl = new String[animCount];
				String temp;

				for (int j = 0; j < animCount; j++) {
					temp = dis.readUTF();
					if (temp.length() < 2) {
						temp = null;
					}
					resUrl[j] = temp;// 动画URL
				}
				byte vip = 0;
				String appellation = null;
				String family = null;
				byte zq_type = 0;
				byte appellation_color = 0;
				if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {
					family = dis.readUTF();
					vip = dis.readByte();
					appellation_color = dis.readByte();
					appellation = dis.readUTF();
					zq_type = dis.readByte();
				}
				int speed = dis.readShort();// 角色速度
				if (id == m_controlledActor.m_gameID) {
					ActorRole role = (ActorRole) m_controlledActor;
					role.m_type = type;
					role.m_appellation_color = appellation_color;
					role.m_appellation = appellation;
					role.m_vip_lv = vip;
					role.m_family_name = family;
					role.m_velocity = speed / GameManager.FRAME_PER_SECOND << Actor.ACTOR_FRACTION_BIT;
					Tools.debugPrintln("<<<<<>>>>>>>>>同屏更新处：玩家自己的速度="+role.m_velocity+";speed="+speed);
				}
				else if (type == AbstractGameActor.ACTOR_TYPE_ROLE) {// 更新动态角色
					ActorRole role = getRoleByID(id);
					if (role == null) {
						Tools.debugPrintln("更新角色形象失败 ,无法找到该角色--id:" + id);
						continue;
					}
					role.m_type = type;
					role.m_appellation_color = appellation_color;
					role.m_appellation = appellation;
					role.m_vip_lv = vip;
					role.m_family_name = family;
					String url = null;
					boolean urlok = false;
					for (int k = 0; k < animCount; k++) {
						urlok = (resUrl[k] != null && resUrl[k].length() > 1);
						Tools.debugPrintln("名字："+role.m_name+";urlok=" + urlok + ";resUrl[" + k + "]=" + resUrl[k]);
						switch (k) {
							case 0:// 坐骑
							case 2:// 武器
								if (urlok) {// URL 不NULL
									url = ObjectAdapter.DIR_ANIM.concat(resUrl[k]).concat(ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
									if (role.m_refsResHead[k] == null) {// 如果当前资源列表为空
										role.m_refsResHead[k] = new ResHead();
										role.m_refsResHead[k].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;// 读取角色动画资源类型
										role.m_refsResHead[k].m_version = 1;// 读取角色动画资源版本
										role.m_refsResHead[k].m_url = url;
										role.m_anims[k] = null;
									}
									else {// 当前资源不为空
										if (url.length() > 1 && !role.m_refsResHead[k].m_url.equals(url)) {
											role.m_refsResHead[k].m_url = url;
										}
									}
								}
								else {// URL NULL
									if (role.m_refsResHead[k] != null) {// 如果当前资源列表不空
										role.animsDestroy(role.m_anims[k], role.m_refsResHead[k]);
										role.m_anims[k] = null;
										role.m_refsResHead[k] = null;
									}
								}
								break;
							case 1:// 角色
								if (urlok) {
									url = GameManager.getInstance().getClothHead(role.m_sex, role.m_race);
									url = ObjectAdapter.DIR_ANIM.concat(url).concat(resUrl[k]).concat(
											ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
									if (!role.m_refsResHead[k].m_url.equals(url)) {// 是不同URL
										ResHead head = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, url, 1);
										role.m_refsResHead[k] = head;
									}
								}
								break;
						}
					}

					switch (zq_type) {// 更新坐骑类型
						case ActorItemRide.TYPE_SKY:
						case ActorItemRide.TYPE_GROUND:
						case ActorItemRide.TYPE_SWARD:
							if (role.m_ride == null) {
								role.m_ride = new ActorItemRide();
							}
							role.m_isride = true;
							role.m_ride.m_speed = speed/ GameManager.FRAME_PER_SECOND << Actor.ACTOR_FRACTION_BIT;
							role.m_ride.m_rideType = zq_type;
							break;
						default:
							role.m_isride = false;
							role.m_ride = null;
							break;
					}

					Tools.debugPrintln("同屏更新 ----> zq_type=" + zq_type + ";speed=" + speed);
					role.m_velocity = speed / GameManager.FRAME_PER_SECOND << Actor.ACTOR_FRACTION_BIT;
					if (role.m_anims != null && role.m_anims[1] != null) {
						role.m_anim = role.m_anims[1];
					}
					else {
						Tools.debugPrintln("同屏更新时动作出错 role.m_anims[1]=null");
						Tools.debugPrintln("anim name : " + role.m_refsResHead[1]);
					}
				}
				else {
					ActorNPC npc = getNPCByID(id);
					if (npc == null) {
						Tools.debugPrintln("更新NPC形象失败 ,无法找到该NPC--id:" + id + "  name:");
						continue;
					}
					npc.m_type = type;
					npc.m_velocity = speed / GameManager.FRAME_PER_SECOND << Actor.ACTOR_FRACTION_BIT;
				}
			}
		}
		catch (Exception e) {
			Tools.debug(e);
		}
	}

	private void recvUpdateItemPicker(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("更新道具拾取权~~");
		short num = dis.readShort();
		ActorNPC item;
		for (int i = 0; i < num; i++) {
			long id = dis.readLong();
			item = getNPCByID(id);
			int pickerNum = dis.readByte();
			synchronized (item) {
				if (pickerNum <= 0) {
					item.m_relatedActorsID = null;
				}
				else {
					item.m_relatedActorsID = new long[pickerNum];
					for (int ii = 0; ii < pickerNum; ii++) {
						item.m_relatedActorsID[ii] = dis.readLong();
					}
				}
			}
		}
	}

	/**
	 * 接收重复登录信息
	 *
	 * @param m_type
	 * @param body
	 */
	public void recvRepeatMessage(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		m_word_repeat = dis.readUTF();
		// Tools.debugPrintln(msg);
		if (state == 0) {
			m_repeat = true;
		}
	}

	/**
	 * 增删玩家金钱
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvRoleMoney(DataInputStream dis) throws IOException
	{
		byte type = dis.readByte();
		long count = dis.readLong();
		Tools.debugPrintln("读取玩家金钱增删 type : " + type + ",count : " + count);
		// 0- 金钱
		// 1- 银票
		// 2- 元宝
		switch (type) {
			case ActorRole.GOLD:
				GameManager.getInstance().m_role.m_money_game += count;
				break;
			case ActorRole.YINPIAO:
				GameManager.getInstance().m_role.m_money_yinpiao += count;
				break;
			case ActorRole.YUANBAO:
				GameManager.getInstance().m_role.m_money_rmb += count;
				break;
			case ActorRole.ZHANGONG:
				GameManager.getInstance().m_role.m_money_zhangong += count;
				break;
			case ActorRole.BANGGONG:
				GameManager.getInstance().m_role.m_money_banggong += count;
				break;
		}
	}

	private void recvRoleExp(DataInputStream dis) throws IOException
	{
		GameManager.getInstance().m_role.m_exp = dis.readInt();
		Tools.debugPrintln("同步当前玩家经验 : " + GameManager.getInstance().m_role.m_exp);
	}

	// /**
	// * 读取队伍信息
	// * @param m_type
	// * @param body354455044371407
	// */
	// public void recvViewTeam(DataInputStream dis) throws IOException
	// {
	// short state = dis.readShort();
	// String msg = dis.readUTF();
	// Tools.debugPrintln("状态码 : " + state);
	// if (state == 1) {
	// byte teamState = dis.readByte();
	// ActorRole role = GameManager.getInstance().m_role;
	// Tools.debugPrintln("队伍状态 : " + teamState);
	// if (teamState == 0) {
	// role.m_roleTeam = null;
	// }
	// else {
	// byte teamNum = dis.readByte();
	// Tools.debugPrintln("创建队伍人数 : " + teamNum);
	// role.m_roleTeam = null;
	// role.m_roleTeam = new ActorRole[teamNum];
	// for (byte i = 0, j = 0; i < teamNum; i++) {
	// int id = dis.readInt();
	// byte captain = dis.readByte();
	// ActorRole ar = getRoleById(id);
	// if (ar != null) {
	// role.m_roleTeam[j] = ar;
	// role.m_roleTeam[j].m_captain = captain;
	// Tools.debugPrintln("队伍加入一个玩家 : " + role.m_roleTeam[j].m_name);
	// j++;
	// continue;
	// }
	// else {
	// Tools.debugPrintln("没有找到ID" + id + "的玩家");
	// }
	// }
	// }
	// //更新UI中的队友头像
	// UiManager.getInstance().teammateChanged();
	// }
	// else {
	// Tools.debugPrintln("读取队伍信息失败  : " + msg);
	// }
	// }

	private void recvBattleUpdate(DataInputStream dis) throws IOException
	{
		int roleID = dis.readInt();
		int actionID = dis.readInt();
		int damageHp = dis.readInt();
		byte roleState = dis.readByte();
		// if (m_dynamic_actors != null) {
		// ActorRole actorRole;
		// for (int i = 0; i < m_dynamic_actors.size(); i++) {
		// // Tools.debugPrintln("查找ID : " + m_dynamic_actors[i].m_gameID);
		// if (m_dynamic_actors.elementAt(i) != null && ((Actor)
		// m_dynamic_actors.elementAt(i)).m_gameID == roleID) {
		// actorRole = (ActorRole) m_dynamic_actors.elementAt(i);
		// actorRole.m_default_state = roleState;
		// if (damageHp < 0) {
		// actorRole.m_damage_hp = damageHp;
		// actorRole.m_damage_y = 40;
		// }
		// switch (roleState) {
		// case ActorRole.DEFAULT_STATE_ATTACK:
		// actorRole.setAction(actionID, false, false);
		// break;
		// case ActorRole.DEFAULT_STATE_HIT:
		// actorRole.setAction(ActorRole.ACTION_STATE_START_HURT
		// + actionID % ActorRole.ACTION_STATE_EACH_COUNT, false, false);
		// break;
		// case ActorRole.DEFAULT_STATE_DEAD:
		// actorRole.setAction(ActorRole.ACTION_STATE_START_DEAD
		// + actionID % ActorRole.ACTION_STATE_EACH_COUNT, false, false);
		// break;
		// }
		// }
		// }
		// }
		Tools.debugPrintln("玩家ID : 动作ID : 损血 : 玩家状态 -> " + roleID + " : " + actionID + " : " + damageHp + " : "
				+ roleState);
	}

	/**
	 * 读取商店
	 *
	 * @param dis
	 * @throws IOException
	 */
	public void recvBusiness(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
			String shopName = dis.readUTF();// 商店名称
			Tools.debugPrintln("商店名称 : " + shopName);
			byte size = dis.readByte();
			Tools.debugPrintln("商品数量 : " + size);
			for (byte i = 0; i < size; i++) {
				int id = dis.readInt();// ID
				int icon = dis.readInt();// 图标
				String name = dis.readUTF();// 名字
				int lv = dis.readInt();// 等级
				byte ranking = dis.readByte();// 品阶
				Tools.debugPrintln("ID : " + id + ", icon : " + icon + ", 名字 : " + name + ", 等级 : " + lv + ", 品阶 : "
						+ ranking);
			}
		}
		else {
			Tools.debugPrintln(msg);
		}
	}

	/**
	 * 查看人物信息
	 *
	 * @param dis
	 * @throws IOException
	 */
	public void recvRoleView(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
		}
		else {
			Tools.debugPrintln("查看玩家信息异常 : " + msg);
		}
	}

	/*****************************/
	// 气泡 zeng
	/*****************************/

	/**
	 * 2012-2-17 上午09:23:55 venizeng
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvInteract(DataInputStream dis) throws IOException
	{
		// Tools.debugPrintln("获得气泡文字");
		String key = dis.readUTF();
		String content = dis.readUTF();
		// Tools.debugPrintln("Key = " + key + " Content = " + content);
		UiInteractMenu.openInteractMenu(key, content);
	}

	/*****************************/
	// Mail zeng
	/*****************************/

	/**
	 * 新邮件提示
	 *
	 * @param dis
	 * @throws IOException
	 */
	public final void recvMailWarn(DataInputStream dis) throws IOException
	{
		MailItem.s_num_newMail = dis.readShort();
	}

	private void recvPetList(DataInputStream dis) throws IOException
	{
		byte num2 = dis.readByte();
		for (byte j = 0; j < num2; j++) {
			byte type = dis.readByte();
			if (type != -1) {
				int num = dis.readInt();
				for (int i = 0; i < num; i++) {
					int petId = dis.readInt();
					String petname = dis.readUTF();
					String petrace = dis.readUTF();
					String petpinjie = dis.readUTF();
					String petlevel = dis.readUTF();
					Tools.debugPrintln("宠物ID = " + petId);
					Tools.debugPrintln("宠物名称 = " + petname);
					Tools.debugPrintln("宠物种族 = " + petrace);
					Tools.debugPrintln("宠物品阶 = " + petpinjie);
					Tools.debugPrintln("宠物级别 = " + petlevel);
				}
			}
			else {
				Tools.debugPrintln("无宠物列表");
			}
		}
	}

	private void recvAbolishAllCombatSkill(DataInputStream dis) throws IOException
	{
		// 状态码和描述
		int state = dis.readShort();
		String descp = dis.readUTF();
		if (state == 0) {
			if (!descp.equals("")) {
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, descp);
			}
			return;
		}
		else {
			if (!descp.equals("")) {
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, descp);
			}
		}
		updateShortcutAndMarcoOnSkillChanged(dis);
	}

	private void updateShortcutAndMarcoOnSkillChanged(DataInputStream dis) throws IOException
	{
		// 记录原有的技能Id
		long[][] ids = null;
		ActorRole role = GameManager.getInstance().m_role;
		RoleCombatSkill[][] skills = role.m_roleCombatSkill;
		if (skills != null) {
			ids = new long[skills.length][];
			for (int i = 0; i < skills.length; i++) {
				if (skills[i] == null) {
					continue;
				}
				ids[i] = new long[skills[i].length];
				for (int j = 0; j < skills[i].length; j++) {
					ids[i][j] = skills[i][j].m_id;
				}
			}
		}
		//
		GameManager.getInstance().m_role.initCombatSkill(dis);
		// 更新技能栏
		GameManager.getInstance().m_role.clearShortCutSkillOnSkillChanged();
		// 更新宏
		skills = role.m_roleCombatSkill;
		if (skills == null) {
			return;
		}
		if (ids == null) {
			return;
		}
		for (int i = 0; i < skills.length; i++) {
			if (skills[i] == null) {
				continue;
			}
			if (i >= ids.length) {// 若技能长度变大（觉醒之类）
				return;
			}
			for (int j = 0; j < skills[i].length; j++) {
				if (skills[i] == null || ids[i] == null) {
					continue;
				}
				if (j >= ids[i].length) {// 技能长度可能发生改变
					continue;
				}
				if (skills[i][j].m_id != ids[i][j]) {
					UIMain.updateMarco(ids[i][j], skills[i][j].m_id, i, j);
				}
			}
		}
	}

	/**
	 * 技能更新
	 *
	 * @param dis
	 * @throws IOException
	 */
	public void recvLearnCombatSkill(DataInputStream dis) throws IOException
	{
		// 状态码和描述
		int state = dis.readShort();
		String descp = dis.readUTF();
		if (state == 0) {
			if (!descp.equals("")) {
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, descp);
			}
			return;
		}
		else {
			if (!descp.equals("")) {
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, descp);
			}
		}
		GameManager.getInstance().m_role.setCombatSKill(dis);
	}

	/**
	 * 施法
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvCastSkill(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("收到指令：" + GameProtocol.CS_CAST_SKILL);
		// 状态码和描述
		int state = dis.readShort();
		String descp = dis.readUTF();
		short id = dis.readShort();
		Tools.debugPrintln("重置技能id="+id);
		// ChatItem msg = ChatItem.createChatItem(ChatItem.TYPE_XI, -1, "",
		// descp);
		// GameManager.getInstance().m_role.m_list_chats.addElement(msg);
		// addMessage(descp, Tools.RED, Tools.BLACK);
		Tools.debugPrintln("施法状态 : " + state);
		if (state == 0) {
			addMessage(descp, Tools.RED, Tools.BLACK);
			ActorRole role = GameManager.getInstance().m_role;
			// CD重置
			RoleCombatSkill comskill = role.getCombatSkill(id);
			if (comskill != null) {
				Tools.debugPrintln("重置技能名字="+comskill.m_name);
				comskill.m_cd_counter = 0;
				Tools.debugPrintln("======================重置技能CD为0==========================");
			}
			else {
				if (role.m_curCombatSkill != null) {
					((RoleCombatSkill) role.m_curCombatSkill).m_cd_counter = 0;
					Tools.debugPrintln("======================重置技能CD为0==========================");
				}
			}
			// 公共CD重置
			role.m_publicCD_skill = role.m_publicCD_skill_counter = 0;
			// 停止施法
			role.m_isCasting = false;
			role.stopCasting();
			role.stopCastingDescription();
			if (role.m_status != ActorRole.ACTOR_STATUS_ROLE_DEAD) {
				role.setAction(ActorRole.ACTION_STAND * ActorRole.DIRECT_NUM + role.m_direct, 0, 0, true, false);
			}
		}
	}

	/**
	 * 读取施放技能位移
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvCastSkillMove(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 0) {
			int x = dis.readInt();
			int y = dis.readInt();
			GameManager.getInstance().m_role.m_posX = x;
			GameManager.getInstance().m_role.m_posY = y;
			Tools.debugPrintln(msg + " : " + x + " : " + y);
		}
		else {
			Tools.debugPrintln("施放技能位移成功! ");
		}
	}

	// /**
	// * 点击NPC返回信息
	// * @param type
	// * @param body
	// */
	// private void recvNPCInteractive(int type, byte[] body)
	// {
	// ByteArrayInputStream bis = new ByteArrayInputStream(body);
	// DataInputStream dis = new DataInputStream(bis);
	// try {
	// String name = dis.readUTF();
	// int resID = dis.readInt();
	// String dialog = dis.readUTF();
	// int menuSize = dis.readInt();
	//
	// if (menuSize > 0) {
	// for (int i = 0; i < menuSize; i++) {
	// String deion = dis.readUTF();
	// int instruct = dis.readInt();
	// }
	// }
	//
	// dis.close();
	// bis.close();
	// }
	// catch (IOException e) {
	// e.printStackTrace();
	// }
	// }

	/**
	 * 施法转发
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvCastSkillForward(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("收到指令：" + GameProtocol.SC_CAST_SKILL_FORWORD);
		// if (!GameManager.getInstance().m_role.m_combat_status) {
		// GameManager.getInstance().m_role.m_combat_status = true;
		// GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A,
		// "进入战斗!");
		// }
		// GameManager.getInstance().m_role.m_combat_exit_time =
		// AbstractGameActor.COMBAT_EXIT_TIME;

		int casterType = dis.readByte();
		long casterId = dis.readLong();
		AbstractGameActor actor = (AbstractGameActor) getActorById(casterType, casterId);
		if (actor == m_controlledActor) {
			Tools.debugPrintln("施法转发为目标!");
			RoleCombatSkill skill = new RoleCombatSkill();
			skill.m_type = dis.readByte();
			skill.m_targetType = dis.readByte();
			skill.m_id = dis.readShort();
			skill.m_level = dis.readByte();
			skill.m_castingTime = dis.readShort();
			skill.m_castSrcActionId = dis.readShort();
			skill.m_castSrcEffectId = dis.readShort();
			skill.m_castTgtActionId = dis.readShort();
			skill.m_castTgtEffectId = dis.readShort();
			// RoleCombatSkill skill = ((RoleCombatSkill)
			// actor.m_curCombatSkill);
			if (skill.m_type == RoleCombatSkill.TYPE_SING) {
				actor.setAction(skill.m_castSrcActionId * AbstractGameActor.DIRECT_NUM + actor.m_direct, true);
				GameManager.getInstance().m_role.m_isCasting = false;
				GameManager.getInstance().m_role.stopCasting();
				GameManager.getInstance().m_role.stopCastingDescription();
				addEffect(skill.m_castSrcEffectId, actor.m_posX, actor.m_posY);
			}
			int targetNum = dis.readByte();
			Vector list = ((ActorRole) actor).m_targetDamage;
			list.removeAllElements();
			for (int i = 0; i < targetNum; i++) {
				byte type = dis.readByte();
				long id = dis.readLong();
				int value = dis.readInt();
				byte atk_r = dis.readByte();
				list.addElement(new long[] { type, id, value, atk_r });
				Actor tgtActor = getActorById(type, id);
				if (tgtActor != null) {
					addEffect(skill.m_castTgtEffectId, tgtActor.m_posX, tgtActor.m_posY);
				}
			}
//			// 以第一个目标为焦点施放光效
//			if (list.size() > 0 && skill.m_castTgtEffectId >= 0) {
//				long[] tgt = (long[]) list.elementAt(0);
//				byte type = (byte) tgt[0];
//				long id = tgt[1];
//				Actor tgtActor = getActorById(type, id);
//				if (tgtActor != null) {
//					addEffect(skill.m_castTgtEffectId, tgtActor.m_posX, tgtActor.m_posY);
//				}
//			}
			actor.mpChanged(skill.m_consumption);
		}
		else if (actor instanceof ActorRole) {
			RoleCombatSkill skill = new RoleCombatSkill();
			skill.m_type = dis.readByte();
			skill.m_targetType = dis.readByte();
			skill.m_id = dis.readShort();
			skill.m_level = dis.readByte();
			skill.m_castingTime = dis.readShort();
			skill.m_castSrcActionId = dis.readShort();
			skill.m_castSrcEffectId = dis.readShort();
			skill.m_castTgtActionId = dis.readShort();
			skill.m_castTgtEffectId = dis.readShort();
			int targetNum = dis.readByte();
			Vector list = ((ActorRole) actor).m_targetDamage;
			list.removeAllElements();
			for (int i = 0; i < targetNum; i++) {
				byte type = dis.readByte();
				long id = dis.readLong();
				int value = dis.readInt();
				byte atk_r = dis.readByte();
				list.addElement(new long[] { type, id, value, atk_r });
				Actor tgtActor = getActorById(type, id);
				if (tgtActor != null) {
					addEffect(skill.m_castTgtEffectId, tgtActor.m_posX, tgtActor.m_posY);
				}
			}
			actor.m_curCombatSkill = null;
			actor.m_curCombatSkill = skill;
			if (list.size() > 0) {
				long[] tInfo = (long[]) list.elementAt(0);
				AbstractGameActor target = (AbstractGameActor) getActorById((int) tInfo[0], tInfo[1]);
				actor.changeDirectToTarget(target);
			}
			switch (skill.m_type) {
				case RoleCombatSkill.TYPE_COMMON:
				case RoleCombatSkill.TYPE_SING: {
					if (skill.m_castSrcActionId >= 0) {
						actor.setAction(skill.m_castSrcActionId * AbstractGameActor.DIRECT_NUM + actor.m_direct, 0, 0,
								false, true);
						addEffect(skill.m_castSrcEffectId, actor.m_posX, actor.m_posY);
					}
					break;
				}
				case RoleCombatSkill.TYPE_CONTINUOUS: {
					if (skill.m_castSrcActionId >= 0) {
						actor.setAction(skill.m_castSrcActionId * AbstractGameActor.DIRECT_NUM + actor.m_direct, 0, 0,
								false, false);
						addEffect(skill.m_castSrcEffectId, actor.m_posX, actor.m_posY);
					}
					break;
				}
			}

			// 以第一个目标为焦点施放光效
//			if (list.size() > 0 && skill.m_castTgtEffectId >= 0) {
//				long[] tgt = (long[]) list.elementAt(0);
//				byte type = (byte) tgt[0];
//				long id = tgt[1];
//				Actor tgtActor = getActorById(type, id);
//				if (tgtActor != null) {
//					addEffect(skill.m_castTgtEffectId, tgtActor.m_posX, tgtActor.m_posY);
//				}
//			}
		}
		else {
			Tools.debugPrintln("cast skill forward error：5205");
		}
	}

	/**
	 * 怪物施法转发
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvNPCSkillForward(DataInputStream dis) throws IOException
	{
		int casterType = dis.readByte();
		long casterId = dis.readLong();
		AbstractGameActor actor = (AbstractGameActor) getActorById(casterType, casterId);
		if (actor instanceof ActorNPC) {
			CombatSkill skill = new CombatSkill();
			skill.m_type = dis.readByte();
			skill.m_castSrcActionId = dis.readShort();
			skill.m_castSrcEffectId = dis.readShort();
			skill.m_castTgtEffectId = dis.readShort();
			skill.m_castTgtEffectId = dis.readShort();

			int targetNum = dis.readByte();

			Vector list = ((ActorNPC) actor).m_targetDamage;
			list.removeAllElements();
			for (int i = 0; i < targetNum; i++) {
				byte type = dis.readByte();
				long id = dis.readLong();
				int value = dis.readInt();
				byte atk_r = dis.readByte();
				list.addElement(new long[] { type, id, value, atk_r });
				Actor tgtActor = getActorById(type, id);
				if (tgtActor != null) {
					addEffect(skill.m_castTgtEffectId, tgtActor.m_posX, tgtActor.m_posY);
				}
			}

			((ActorNPC) actor).m_curCombatSkill = null;
			((ActorNPC) actor).m_curCombatSkill = skill;

			if (list.size() > 0) {
				long[] tInfo = (long[]) list.elementAt(0);
				AbstractGameActor target = (AbstractGameActor) getActorById((int) tInfo[0], tInfo[1]);
				actor.changeDirectToTarget(target);
			}
			if (skill.m_castSrcActionId >= 0) {
				actor.setAction(skill.m_castSrcActionId * ActorNPC.DIRECT_NUM + actor.m_direct, 0, 0, false, true);
			}
			addEffect(skill.m_castSrcEffectId, actor.m_posX, actor.m_posY);
		}
	}

	/**
	 * 更新buffer信息
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvBufferUpdate(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("更新buffer：" + GameProtocol.SC_BUFFER_UPDATE);
		int type = dis.readByte();
		long id = dis.readLong();

		AbstractGameActor actor = (AbstractGameActor) getActorById(type, id);
		if (actor != null) {
			actor.m_status = dis.readByte();
			actor.m_action = dis.readInt();
			int num = dis.readByte();
			for (int i = 0; i < num; i++) {
				byte aord = dis.readByte(); // 添加或删除
				byte bufType = dis.readByte();
				long bufId = dis.readLong();
				// 删除
				if (aord == 0) {
					if (bufType == 0) {// 增益
						actor.removeBuf(bufId);
					}
					else {// 减益
						actor.removeDeBuf(bufId);
					}
					Tools.debugPrintln("删除buffer：" + bufId);
				}
				// 添加
				else {
					short iconId = dis.readShort();
					int duration = dis.readInt();
					if (bufType == 0) {// 增益
						actor.addBuf(bufId, iconId, duration);
					}
					else {// 减益
						actor.addDebuf(bufId, iconId, duration);
					}
					Tools.debugPrintln("添加buffer：" + actor.m_gameID + " : " + bufType + " : " + bufId + ", 持续时间："
							+ duration);
				}
			}
		}
	}

	/**
	 * 行为更新
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvActionUpdate(DataInputStream dis) throws IOException
	{
		int type = dis.readByte();
		long id = dis.readLong();
		AbstractGameActor actor = (AbstractGameActor) getActorById(type, id);
		if (actor == null) {
			Tools.debugPrintln("更新行为失败id为空!" + id);
			return;
		}
		actor.m_action = dis.readInt();
		Tools.debugPrintln("战斗行为更新ID : " + id + ",行为 : " + actor.m_action);
	}

	/**
	 * 更新状态
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvStateUpdate(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("收到指令：" + GameProtocol.SC_STATE_UPDATE);
		int type = dis.readByte();
		long id = dis.readLong();
		AbstractGameActor actor = (AbstractGameActor) getActorById(type, id);
		if (actor == null) {
			Tools.debugPrintln("更新状态失败id为空!" + id);
			return;
		}
		else {
			Tools.debugPrintln("战斗状态更新ID : " + id+";type="+type);
		}
		byte status = dis.readByte();
		Tools.debugPrintln("state update : " + actor.m_gameID + " : " + status);
		if (status == AbstractGameActor.ACTOR_STATUS_ROLE_DEAD || status == AbstractGameActor.ACTOR_STATUS_NPC_DEAD) {
			switch (type) {
				case AbstractGameActor.ACTOR_TYPE_ROLE:
					Tools.debugPrintln("<MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM>");
					actor.setAction(ActorRole.ACTION_DEAD1 * ActorRole.DIRECT_NUM + actor.m_direct, 0, 0, false, false);
					break;
				case AbstractGameActor.ACTOR_TYPE_MONSTER:
				case AbstractGameActor.ACTOR_TYPE_NPC:
					actor.setAction(ActorNPC.ACTION_DEAD1 * ActorNPC.DIRECT_NUM + actor.m_direct, 0, 0, false, false);
					break;
			}
			if (m_controlledActor.m_targetActor != null) {
				Tools.debugPrintln("目标ID : " + m_controlledActor.m_targetActor.m_gameID);
			}
			// 目标死亡则将焦点移除
			if (actor == m_controlledActor.m_targetActor) {
				Tools.debugPrintln("目标被干死!");
				actor.m_hp = 0;
				actor.clearBufAndDebuf();
				setTargetActor(null);
			}

			// 如果死亡的是自己，则执行dead()
			if (actor == m_controlledActor) {
				actor.m_hp = 0;
				actor.dead();
				GameManager.getInstance().m_role.keyAnyStopOther();
				if (actor.m_status == AbstractGameActor.ACTOR_STATUS_ROLE_COMBAT) {
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "离开战斗!");
				}
			}
		}
		else if (status == AbstractGameActor.ACTOR_STATUS_ROLE_COMBAT
				|| status == AbstractGameActor.ACTOR_STATUS_NPC_COMBAT) {
			switch (type) {
				case AbstractGameActor.ACTOR_TYPE_ROLE:
					if (actor.m_status != AbstractGameActor.ACTOR_STATUS_ROLE_COMBAT
							&& id == m_controlledActor.m_gameID) {
						GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "进入战斗!");
//						if (GameManager.getInstance().m_role.m_isride)
//							GameManager.getInstance().m_game_message.sendRideClose();
					}
					break;
				case AbstractGameActor.ACTOR_TYPE_MONSTER:
				case AbstractGameActor.ACTOR_TYPE_NPC:
					break;
			}
		}
		else if (status == AbstractGameActor.ACTOR_STATUS_ROLE_FREE
				|| status == AbstractGameActor.ACTOR_STATUS_NPC_FREE) {
			switch (type) {
				case AbstractGameActor.ACTOR_TYPE_ROLE:
					if (actor.m_status == AbstractGameActor.ACTOR_STATUS_ROLE_DEAD) {
						actor.setAction(ActorRole.ACTION_STAND * ActorRole.DIRECT_NUM + actor.m_direct, 0, 0, true,
								true);
					}
					if (actor.m_status == AbstractGameActor.ACTOR_STATUS_ROLE_COMBAT
							&& id == m_controlledActor.m_gameID) {
						GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "离开战斗!");
					}
					break;
				case AbstractGameActor.ACTOR_TYPE_MONSTER:
				case AbstractGameActor.ACTOR_TYPE_NPC:
					actor.setAction(ActorNPC.ACTION_STAND * ActorNPC.DIRECT_NUM + actor.m_direct, 0, 0, true, true);
					break;
			}
		}
		actor.m_status = status;
	}

	/**
	 * 吟唱转发
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvSingForward(DataInputStream dis) throws IOException
	{
		int type = dis.readByte();
		long id = dis.readLong();
		int actionId = dis.readShort();
		int effectId = dis.readShort();
		Tools.debugPrintln("吟唱转发!" + type + " : " + id + " : " + actionId + " : " + effectId);
		switch (type) {
			case AbstractGameActor.ACTOR_TYPE_ROLE:
				ActorRole role = (ActorRole) getActorById(type, id);
				if (role != null) {
					Tools.debugPrintln("转发玩家 : " + role.m_name);
					if (role != m_controlledActor) {
						role.setAction(actionId * AbstractGameActor.DIRECT_NUM + role.m_direct, 0, 0, true, true);
						addEffect(effectId, role.m_posX, role.m_posY);
					}
					else {
						dis.skip(dis.available());
					}
				}
				break;
			case AbstractGameActor.ACTOR_TYPE_MONSTER:
			case AbstractGameActor.ACTOR_TYPE_NPC:
				ActorNPC npc = (ActorNPC) getActorById(type, id);
				if (npc != null) {
					npc.setAction(actionId * AbstractGameActor.DIRECT_NUM + npc.m_direct, 0, 0, true, true);
					addEffect(effectId, npc.getActiveBoxCenterX(), npc.getActiveBoxCenterY());
				}
				break;
		}
	}

	private void recvDotOrHotNum(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("Dot在跳！！" + GameProtocol.SC_DOT_HOT);
		byte type = dis.readByte();
		long id = dis.readLong();
		int hValue = dis.readInt();
		byte result = dis.readByte();
		boolean crit = (result & 0x01) == 1; // 是否暴击
		boolean miss = (result & 0x02) == 0; // 是否命中
		// boolean interrupt = (result & 0x04) == 1; // 是否打断
		AbstractGameActor r = (AbstractGameActor) getActorById(type, id);
		if (r != null) {
			int imgId = 0;
			if (!miss) {
				imgId = ((hValue >= 0 ? 0 : 1) << 1) | (crit ? 1 : 0);
			}
			else {
				imgId = GameScene.DAMAGE_NUM_IMGID_MISS;
			}
			int[] data = new int[7];
			data[GameScene.DAMAGE_NUM_IMGID] = imgId;
			data[GameScene.DAMAGE_NUM_X] = Tools.random(r.m_posX - m_cameraX - 5, r.m_posX - m_cameraX + 5);
			data[GameScene.DAMAGE_NUM_Y] = Tools.random(r.m_posY - m_cameraY - r.DAMAGE_NUM_OFFSETY - 5, r.m_posY
					- m_cameraY - r.DAMAGE_NUM_OFFSETY + 5);
			data[GameScene.DAMAGE_NUM_W] = GameScene.SIZE_IMG_DAMAGENUM[imgId][0];
			data[GameScene.DAMAGE_NUM_H] = GameScene.SIZE_IMG_DAMAGENUM[imgId][1];
			data[GameScene.DAMAGE_NUM_VALUE] = hValue;
			data[GameScene.DAMAGE_NUM_DURATION] = 10;
			addDamageNum(data);
		}
	}

	private void recvPickItem(DataInputStream dis) throws IOException
	{
		short state = dis.readByte();
		long id = dis.readLong();
		Long lid = new Long(id);
		Tools.debugPrintln("拾取结果：" + state);
		switch (state) {
			case 0: // 成功
				Tools.debugPrintln("拾取成功:" + id);
				ActorNPC item = getNPCByID(id);
				if (item != null) {
					item.deactivate();
				}
				break;
			case 1: // 背包满
				GameManager.getInstance().m_role.m_pickItem_protectTime = ActorRole.PICK_ITEM_PROTECT_TIME;
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "您背包已满");
				break;
		}
		GameManager.getInstance().m_role.m_pickItem_IDs.removeElement(lid);
	}

	/**
	 * 更新buff时间
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvUpdateBuffTime(DataInputStream dis) throws IOException
	{
		long id = dis.readLong();
		int time = dis.readInt();
		Tools.debugPrintln("更新buf id : " + id);
		ActorBuffer buf = m_controlledActor.getBufByID(id);
		if (buf != null) {
			buf.m_duration = time * GameManager.FRAME_PER_SECOND;
		}
	}

	/**
	 * 更新mode
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvUpdateMode(DataInputStream dis) throws IOException
	{
		GameManager.getInstance().m_role.m_mode = (byte) dis.readInt();
		Tools.debugPrintln("更新角色mode : " + GameManager.getInstance().m_role.m_mode);
	}

	// /**
	// * 离开战斗
	// *
	// * @param dis
	// * @throws IOException
	// */
	// private void recvOutoCombat(DataInputStream dis) throws IOException
	// {
	// m_controlledActor.m_combating = false;
	// // show tip
	// }

	/**
	 * 服務器主動推送,要求客戶端修改快捷欄 2012-3-8 下午06:44:58 venizeng
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvShrotcutChanged(DataInputStream dis) throws IOException
	{
		byte type = dis.readByte();
		long id = dis.readLong();
		byte index_switch = (byte) (dis.readByte() - 1);
		byte index_shortcut = (byte) (dis.readByte() - 1);
		switch (type) {
			case 1:// 技能
				GameManager.getInstance().m_role.m_shortcut[index_switch][index_shortcut][0] = AbstractGameActor.ACTION_TYPE_SKILL;
				GameManager.getInstance().m_role.m_shortcut[index_switch][index_shortcut][1] = id;
				break;
			case 2:// 物品
				GameManager.getInstance().m_role.m_shortcut[index_switch][index_shortcut][0] = AbstractGameActor.ACTION_TYPE_ITEM;
				GameManager.getInstance().m_role.m_shortcut[index_switch][index_shortcut][1] = id;
				break;
			case 3:// 功能
				GameManager.getInstance().m_role.m_shortcut[index_switch][index_shortcut][0] = AbstractGameActor.ACTION_TYPE_FUNCTION;
				GameManager.getInstance().m_role.m_shortcut[index_switch][index_shortcut][1] = id;
				break;
		}
		GameManager.getInstance().m_game_message.sendSetShortCut(GameManager.getInstance().m_role.m_shortcut);
	}

	/**
	 * 接收装备修理提示 - 耐久过低 2012-4-9 上午10:03:35 venizeng
	 *
	 * @param dis
	 */
	private void recvEquipFixAlert(DataInputStream dis)
	{
		GameManager.getInstance().m_role.m_isNeedFix = true;
	}

	/**
	 * 聊天
	 *
	 * @throws IOException
	 */
	private void recvChatInfos(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("获得聊天信息 ------------------");
		ChatItem item = ChatItem.readChatInfos(dis);
		GameManager.getInstance().m_role.addToChat(item);;
	}

//	private void addItemLimit(ChatItem item)
//	{
//		Tools.debugPrintln("item.m_type="+item.m_type);
//		Tools.debugPrintln("item content:"+item.m_content);
//		byte state = 1;
//		switch (item.m_type) {
//			case ChatItem.TYPE_SI:
//				state = GameManager.s_system_infos[GameManager.SET_CHANNEL_PRIVATE];
//				break;
//			case ChatItem.TYPE_TEAM:
//				state = GameManager.s_system_infos[GameManager.SET_CHANNEL_RANKS];
//				break;
//			case ChatItem.TYPE_QU:
//				// state =
//				// GameManager.s_system_infos[GameManager.SET_CHANNEL_PRIVATE];
//				break;
//			case ChatItem.TYPE_WORLD:
//				state = GameManager.s_system_infos[GameManager.SET_CHANNEL_WORLD];
//				break;
//			case ChatItem.TYPE_XI:
//				state = GameManager.s_system_infos[GameManager.SET_CHANNEL_SYSTEM];
//				break;
//			case ChatItem.TYPE_FAMILY:
//				state = GameManager.s_system_infos[GameManager.SET_CHANNEL_FMAILY];
//				break;
//			case ChatItem.TYPE_REALM:
//				state = GameManager.s_system_infos[GameManager.SET_CHANNEL_CAMP];
//				break;
//		}
//		if (state == 0) {
//			return;// 屏蔽
//		}
//		GameManager.getInstance().m_role.addToChat(item);
//	}

	private void recvChatWorld(DataInputStream dis)
	{
		byte state = 0;
		try {
			state = dis.readByte();
		}
		catch (IOException e) {
		}
		if (state == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "没有大喇叭，无法发言");
		}
	}

	private String recvReadHint(DataInputStream dis) throws IOException
	{
		// String text = HyperLink.replaceContent(dis.readUTF());
		// text = HyperLink.replaceMark(text);
		return AbsHyperLinker.removeHyper(dis.readUTF());
	}

	public static void recvInfo(DataInputStream dis) throws IOException
	{
		long id_sender = dis.readLong();
		String name = dis.readUTF();
		byte type = dis.readByte();
		String info = dis.readUTF();
		String temp = type < 10 ? "0" + type : String.valueOf(type);
		ChatItem item = null;
		if (id_sender == ChatItem.ID_SYSTEM) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_E, temp + info);
			item = ChatItem.createChatItem(ChatItem.TYPE_XI, id_sender, "系", "您", info);
		}
		else {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_E, temp + name + ":" + info);
			item = ChatItem.createChatItem(ChatItem.TYPE_WORLD, id_sender, name, "您", info);
		}
		GameManager.getInstance().m_role.addToChat(item);
	}

	public boolean recvMessage(int type, byte[] body)
	{
		try {
			int order = BaseConnection.s_perseOrderID;
			ByteArrayInputStream bais = new ByteArrayInputStream(body);
			DataInputStream dis = new DataInputStream(bais);
			if (body != null) {
				//zuobi 挂机
				if( ActorRole.m_guaji ){
					if(order == GameProtocol.SC_TEAM_AGREE //组队请求
						|| order == GameProtocol.SC_SOCIAL_CONFIRMATION//好友
						|| order == GameProtocol.SC_DUEL_QUERY){//切磋
						return true;
					}
				}
				synchronized (this) {
					switch (order) {
						case GameProtocol.CS_USER_REPEAT:
							// recvRepeatMessage(type, body);
							break;
							//NPC用户中心
						case GameProtocol.SC_NPC_USER_CHANGE_PASSWORD:
							Tools.debugPrintln("NPC修改密码！");
							UIUserManager.recvNpcUser(UIUserManager.ACCOUNT_MANAGE_PASSWORD);
							break;
						case GameProtocol.SC_NPC_USER_BINDING:
							Tools.debugPrintln("NPC账号绑定！");
							UIUserManager.recvNpcUser(UIUserManager.ACCOUNT_MANAGE_BINDING);
							break;
						case GameProtocol.SC_NPC_USER_RETRIEVE_PASSWORD:
							Tools.debugPrintln("NPC找回密码！");
							UIUserManager.recvNpcUser(UIUserManager.ACCOUNT_MANAGE_BACK);
							break;
						case GameProtocol.SC_NPC_USER_UNBIND:
							Tools.debugPrintln("NPC解除绑定！");
							UIUserManager.recvNpcUser(UIUserManager.ACCOUNT_MANAGE_UNBIND);
							break;
						case GameProtocol.SC_USER_CHANGE_PASSWORD:
						case GameProtocol.SC_USER_BINDING:
						case GameProtocol.SC_USER_RETRIEVE_PASSWORD:
						case GameProtocol.SC_USER_UNBIND:
							if( UIUserManager.m_instance != null){
								Tools.debugPrintln("读取NPC用户中心数据");
								UIUserManager.m_instance.recvMessage(type, body);
							}else{
								Tools.debugPrintln("读取NPC用户中心数据异常！");
							}
							break;
						case GameProtocol.SC_HINT_A:
							Tools.debugPrintln("读取A类提示!");
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, recvReadHint(dis));
							break;
						case GameProtocol.SC_HINT_B:
							Tools.debugPrintln("读取B类提示!");
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, recvReadHint(dis));
							break;
						case GameProtocol.SC_HINT_C:
							Tools.debugPrintln("读取C类提示!");
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C, recvReadHint(dis));
							break;
						case GameProtocol.SC_HINT_D:
							Tools.debugPrintln("读取D类提示!");
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_D, recvReadHint(dis));
							break;
						case GameProtocol.SC_HINT_E:
							Tools.debugPrintln("读取E类提示!");
							recvInfo(dis);
							break;
						case GameProtocol.SC_HINT_F:
							Tools.debugPrintln("读取F类提示!");
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_F, recvReadHint(dis));
							break;
//						case GameProtocol.SC_CONFIRMATION_PROMPT://谢亮
//							Tools.debugPrintln("读取确认提示!");
//							recvConfirmationPrompt(dis);
//							break;
						case GameProtocol.SC_SCENE_UPGRADE:
							Tools.debugPrintln("读取升级!");
							recvSceneUpgrade(dis);
							break;
						case GameProtocol.SC_SCENE_POSITION_REVISE:
							recvScenePostionRevise(dis);
							break;
						case GameProtocol.SC_DEAD_POPUPS:// 死亡后弹出窗口
							Tools.debugPrintln("接收死亡后弹出窗口!");
							GameManager.getInstance().m_role.recvDeadPopups(dis);
							break;
						case GameProtocol.SC_REVIVE_CONFIRMATION:// 他人复活确认
							Tools.debugPrintln("他人复活确认!");
							GameManager.getInstance().m_role.recvReviveConfirmation(dis);
							break;
						case GameProtocol.CS_REVIVE_AGREE:// 确认复活
							Tools.debugPrintln("确认复活!");
							GameManager.getInstance().m_role.recvReviveAgree(dis);
							break;
						case GameProtocol.CS_REVIVE_POS:// 原地复活
							Tools.debugPrintln("原地复活!");
							GameManager.getInstance().m_role.recvRevivePos(dis);
							break;
						case GameProtocol.CS_SCENE_PATHFINDING:
							Tools.debugPrintln("读取世界寻路");
							recvScenePathfinding(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_NPC_SETACIONID:
							// Tools.debugPrintln("设置NPC动画!");
							recvNPCsetActionID(dis);
							break;
						case GameProtocol.CS_SCENE_UPDATE:
							// recvUpdateMessage(dis);
							break;
						case GameProtocol.SC_SCENE_ADD_ACTOR:
							recvAddActor(dis);
							break;
						case GameProtocol.SC_SCENE_DELETE_ACTOR:
							recvDeleteActor(dis);
							break;
						case GameProtocol.SC_SCENE_UPDATE_ACTOR_DATA:
							recvUpdateActorData(dis);
							break;
						case GameProtocol.SC_SCENE_UPDATE_ACTOR_FIGURE:
							recvUpdateActorFigure(dis);
							break;
						case GameProtocol.SC_SCENE_UPDATE_ITEM_PICKER:
							recvUpdateItemPicker(dis);
							break;
						case GameProtocol.SC_SCENE_MAP:
							GameManager.getInstance().m_npc_window.recvSceneMap(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_USER_OFFLINE:
							recvOffLineMessage(dis);
							break;
						case GameProtocol.CS_SCENE_BATTLE_UPDATE:
							recvBattleUpdate(dis);
							break;
						case GameProtocol.SC_SCENE_INFORMATION:
							// recvChangeScene(dis);
							break;
						case GameProtocol.SC_SCENE_CONFIRMATION:
							recvSceneConfirmation(dis);
							break;
						case GameProtocol.SC_SCENE_NPC_STATUS:
							recvSceneNPCStatus(dis);
							break;
						case GameProtocol.CS_ATT:
						case GameProtocol.CS_ATT_OTHER:
							UIAttribute.recvMessage(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_TEACH:
							recvTeach(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_GONGLUE:
							UIGonglue.recvMessage(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_NPC_INTERACT_BREAK:
							recvNPCInteractBreak(dis);
							break;
						case GameProtocol.SC_UPDATE_JOB:
							Tools.debugPrintln("更新玩家职业!");
							GameManager.getInstance().m_role.recvUpdateJob(dis);
							break;
						case GameProtocol.SC_UPDATE_MAX_JQ:
							Tools.debugPrintln("更新剑客剑气最大值!");
							GameManager.getInstance().m_role.recvUpdateMaxJQ(dis);
							break;
						case GameProtocol.SC_UPDATE_FACTION:
							GameManager.getInstance().m_role.recvUpdateFaction(dis);
							break;
						/**** 切磋 ****/
						case GameProtocol.SC_DUEL_QUERY:
							Tools.debugPrintln("接收请求决斗询问信息!");
							recvDuelQuery(dis);
							break;
						case GameProtocol.SC_DUEL_COUNT_DOWN:
							Tools.debugPrintln("接收决斗倒计时!");
							recvDuelCountDown(dis);
							break;
						case GameProtocol.SC_DUEL_TEMP_FACTION:
							Tools.debugPrintln("接收决斗临时改变阵营!");
							recvDuelTempFaction(dis);
							break;
						/**** 家族 ****/
						case GameProtocol.CS_FAMILY_CREATE:
							Tools.debugPrintln("接收创建家族" + GameProtocol.CS_FAMILY_CREATE + "!");
							GameManager.getInstance().m_family_window.recvFamilyCreate(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_FAMILY_VERIFY:
							Tools.debugPrintln("接收验证家族" + GameProtocol.CS_FAMILY_VERIFY + "!");
							GameManager.getInstance().m_family_window.recvFamilyVerify(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_OWN_MESSAGE:
							Tools.debugPrintln("接收家族信息" + GameProtocol.SC_FAMILY_OWN_MESSAGE + "!");
							GameManager.getInstance().m_family_window.recvFamilyOwnMessage(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_MODIFY_MANIFESTO:
							Tools.debugPrintln("接收家族宣言" + GameProtocol.SC_FAMILY_MODIFY_MANIFESTO + "!");
							GameManager.getInstance().m_family_window.recvFamilyModifyManifesto(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_MODIFY_NOTICE:
							Tools.debugPrintln("接收家族公告" + GameProtocol.SC_FAMILY_MODIFY_NOTICE + "!");
							GameManager.getInstance().m_family_window.recvFamilyModifyNotice(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_UPDATE_POSITION:
							Tools.debugPrintln("接收更新家族职位" + GameProtocol.SC_FAMILY_UPDATE_POSITION + "!");
							GameManager.getInstance().m_family_window.recvFamilyUpdatePosition(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_INVITE_ADD_NAME:
						case GameProtocol.SC_FAMILY_INVITE_ADD_ID:
							Tools.debugPrintln("接收邀请入族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyInviteAdd(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_MEMBER_LIST:
							Tools.debugPrintln("接收家族成员列表" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyMemberList(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_APPLY_LIST:
							Tools.debugPrintln("接收家族申请列表" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyApplyList(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_APPLY_ADD:
							Tools.debugPrintln("接收申请加入家族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyApplyAdd(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_OTHER_MESSAGE:
							Tools.debugPrintln("接收其他家族信息" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyOtherMessage(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_RATIFY_ADD:
							Tools.debugPrintln("接收批准加入家族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyRatify(dis);
							break;
						// case GameProtocol.SC_FAMILY_APPLY_LEAVE:
						// Tools.debugPrintln("接收申请离开家族" + BaseConnection.s_orderID
						// + "!");
						// GameManager.getInstance().m_family_window.recvFamilyApplyLeave(dis);
						// GameManager.getInstance().m_game_message.unlockNetwork();
						// break;
						case GameProtocol.SC_FAMILY_CONFIRM_LEAVE:
							Tools.debugPrintln("接收确认离开家族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyConfirmLeave(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_EXPEL:
							Tools.debugPrintln("接收开除成员" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyExpel(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_INVITEE_ADD:
							Tools.debugPrintln("接收被邀请入族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyInviteeAdd(dis);
							break;
						case GameProtocol.SC_FAMILY_DISMISS:
							Tools.debugPrintln("接收解散家族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyDismiss(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_CANCEL_DISMISS:
							Tools.debugPrintln("接收取消解散家族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyCancelDismiss(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_SET_ELDER:
							Tools.debugPrintln("接收家族提升/免职长老" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilySetElder(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_DEMISE_SHEIKH:
							Tools.debugPrintln("接收家族禅让族长" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyDemiseSheikh(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_APPLY_MERGE:
							Tools.debugPrintln("接收家族合并家族" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyApplyMerge(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_DONATE:
							Tools.debugPrintln("接收家族捐献物资" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyDonate(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_LUCKY_OPEN:
							Tools.debugPrintln("接收家族抽奖开启" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyLuckOpen(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_FAMILY_LUCKY_RESULT:
							Tools.debugPrintln("接收家族抽奖结果" + order + "!");
							GameManager.getInstance().m_family_window.recvFamilyLuckResult(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						/**** 战场 ****/
						case GameProtocol.SC_BATTLEFIELD_LIST:
							Tools.debugPrintln("接收战场列表" + order + "!");
							UIBattlefieldWindow.recvBattlefieldList(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_BATTLEFIELD_JOIN_QUEUE_RANDOM:
							Tools.debugPrintln("接收加入战场队列" + order + "!");
							UIBattlefieldWindow.recvBattlefieldJoinQueue(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_BATTLEFIELD_EXIT:
							Tools.debugPrintln("接收退出战场" + order + "!");
							UIBattlefieldWindow.recvBattlefieldExit(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_BATTLEFIELD_INTO:
							Tools.debugPrintln("接收进入战场" + order + "!");
							UIBattlefieldWindow.recvBattlefieldInto(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_BATTLEFIELD_CONFIRMATION_INTO:
							Tools.debugPrintln("接收询问进入战场" + order + "!");
							UIBattlefieldWindow.recvBattlefieldconfirmationInto(dis);
							break;
						case GameProtocol.SC_BATTLEFIELD_SCORE:
							Tools.debugPrintln("接收战场得分" + order + "!");
							GameManager.getInstance().m_role.recvBattlefieldScore(dis);
							break;
						case GameProtocol.SC_BATTLEFIELD_DEAD:
							Tools.debugPrintln("接收战场死亡窗口" + order + "!");
							UIBattlefieldWindow.recvBattlefieldDead(dis);
							break;
						case GameProtocol.SC_BATTLEFIELD_FINISH:
							Tools.debugPrintln("接收战场结束" + order + "!");
							UIBattlefieldWindow.recvBattlefieldFinish(dis);
							break;
						case GameProtocol.SC_BATTLEFIELD_FLAG:
							Tools.debugPrintln("接收战场旗子" + order + "!");
							recvBattlefieldFlag(dis);
							break;
						/**** 副本 ****/
						case GameProtocol.SC_GAMECARBON_FINISH:
							Tools.debugPrintln("接收副本通关提示" + order + "!");
							UIGameCarbonWindow.recvGameCarbonFinish(dis);
							break;
						case GameProtocol.CS_GAMECARBON_OPEN:
							Tools.debugPrintln("接收副本界面开启" + order + "!");
							UIGameCarbonWindow.recvGameCarbonOpen(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_GAMECARBON_CHECK:
							Tools.debugPrintln("接收副本检测" + order + "!");
							UIGameCarbonWindow.recvGameCarbonCheck(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_GAMECARBON_AUTO:
							Tools.debugPrintln("接收副本自动组队" + order + "!");
							UIGameCarbonWindow.recvGameCarbonAuto(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_GAMECARBON_UPDATE:
							Tools.debugPrintln("接收副本状态更新" + order + "!");
							UIGameCarbonWindow.recvGameCarbonUpdate(dis);
							break;
						case GameProtocol.CS_GAMECARBON_ADD:
							Tools.debugPrintln("接收副本增次" + order + "!");
							UIGameCarbonWindow.recvGameCarbonAdd(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						/**** 大礼包 ****/
						case GameProtocol.SC_GIFT_BAG_OPEN:
							Tools.debugPrintln("接收开启兑换窗口" + order + "!");
							recvGiftBagOpen(dis);
							break;
						/**** 下线 ****/
						case GameProtocol.S_USER_RESEL: {
							GameManager.getInstance().m_game_message.unlockNetwork();
							GameManager.getInstance().m_role.clearPathfinding();
							GameManager.getInstance().m_role.clearAutoAttack();
							GameManager.getInstance().m_role.closeBattlefieldScore();
							GameManager.getInstance().setReSelStatus(GameManager.GS_RESEL);
							break;
						}
						case GameProtocol.S_SYSTEM_INFO: {
							recvSysInfo(dis);
						}
							break;
						/**** 商城 ****/
						case GameProtocol.CS_BUY_ITEM_WITH_MUL_MONEY:
						case GameProtocol.CS_PRESENT_ITEM_WITH_MUL_MONEY:
						case GameProtocol.S_ACTORITEM_BUY_ALERT:
						case GameProtocol.CS_BUY_FUN_WITH_MUL_MONEY:
						case GameProtocol.S_RMB_GET_ITEM_DOWN:
							UIMultiMoney.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_OPEN_MARKET:
							UIMarket.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						/**** 气泡 ****/
						case GameProtocol.S_INTERACT:
							recvInteract(dis);
							break;
						/**** 设置 ****/
						case GameProtocol.CS_INIT_SHORTCUT:
							GameManager.getInstance().m_role.initShortcut(dis);
							UIMain.updateShortcut();
							break;
						case GameProtocol.CS_INIT_MARCO:
							GameManager.getInstance().m_role.initMarcos(dis);
							break;
						case GameProtocol.CS_SET_SHORTCUT:
							UISetShortCut shortcut = (UISetShortCut) UIManager.getInstance().getWindowById(
									UIWindowFactory.WINDOW_SET_SHORTCUT);
							if (shortcut == null) {// 发送快捷栏给服务器，服务器返回快捷栏设置成功指令
								short state = dis.readShort();
								String info = dis.readUTF();
								if (state == 0) {
									if (!info.equals("")) {
										GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, info);// 正确不提示
									}
								}
							}
							else {// 设置栏设置快捷栏
								shortcut.recvMessage(order, dis);
							}
							UIMain.updateShortcut();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_SET_MARCO: {
							UISetMarco.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
						}
							break;
						/**** 新手引导 ****/
						case GameProtocol.S_PLAY_EUQIP:
							recvPlayTaughtEquip(dis);
							break;
						case GameProtocol.S_PLAY_LEARN_SKILL:
							recvPlayLearnSkill(dis);
							break;
						case GameProtocol.S_PLAY_SET_SKILL:
							recvPlaySetSkill(dis);
							break;
						case GameProtocol.S_PLAY_OPEN_TASK:
							UIMain.gotoTeachOpenTask();// 引导玩家学习*#
							break;
						case GameProtocol.S_SET_SHORTCUT_SKILL:
							recvShrotcutChanged(dis);
							UIMain.updateShortcut();
							break;
						/**** 背包 ****/
						case GameProtocol.CS_ACTORITEM_INFOS:
							GameManager.getInstance().m_role.recvActorItemsFormServer(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_USE:
							GameManager.getInstance().m_role.recvActorItemUse(dis);
							UIMain.updateShortcut();// 快捷栏改变
							ActorItemLBHandler.update();// 更新背包
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_DESTORY:
							GameManager.getInstance().m_role.recvActorItemDestory(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_DISINTEGRATE:
							GameManager.getInstance().m_role.recvActorItemDisintegrate(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_MOVE:
							GameManager.getInstance().m_role.recvActorItemMove(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_EQUIP:
							GameManager.getInstance().m_role.recvActorItemEquip(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_UNINSTALL:
							GameManager.getInstance().m_role.recvActorItemUninstall(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_TRIM:
							GameManager.getInstance().m_role.recvActorItemTrim(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_KUORONG:
							GameManager.getInstance().m_role.recvActorItemKuorong(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_JIEBANG:
							GameManager.getInstance().m_role.recvActorItemJiebang(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_KUORONG_ALERT:
							UIBag.recvKuorongAlert(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_BAOSHI_HECHENG:// //宝石合成
							GameManager.getInstance().m_role.recvActorItemHeCheng(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_BAOSHI_XIANGQIAN:// //宝石镶嵌
							GameManager.getInstance().m_role.recvActorItemXiangqian(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_NIZI_TIQU:// //镊子提取宝石
							GameManager.getInstance().m_role.recvActorItemTiqu(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_ZUOQI_DRIVE:// //坐骑 骑乘
							GameManager.getInstance().m_role.recvActorItemDrive(dis);
							ActorItemLBHandler.update();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_DETAIL:
							UIActorItemDetail.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_QIANGHUA_ENTER:
						case GameProtocol.CS_ACTORITEM_QIANGHUA:
						case GameProtocol.CS_ACTORITEM_QIANGHUA_INFOS:
						case GameProtocol.CS_ACTORITEM_QIANGHUA_NEW:
						case GameProtocol.CS_ACTORITEM_QIANGHUA_INFOS_NEW: {
							UIQianghua.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
						}
							break;
						case GameProtocol.CS_ACTORITEM_QIANGHUA_SPEC: {
							short state = dis.readShort();
							String info = dis.readUTF();
							GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, info);
							GameManager.getInstance().m_game_message.unlockNetwork();
						}
							break;
						case GameProtocol.CS_ACTORITEM_RESOLVE:
							GameManager.getInstance().m_role.recvActorItemResolve(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ACTORITEM_LIMIT:// 当前道具
							GameManager.getInstance().m_role.recvActorItemLitmit(dis);
							break;
						/**** NpcShop ****/
						case GameProtocol.SC_NPC_FIX_EQUIPS:
							Tools.debugPrintln("Fix equip");
							UINpcShop.recvFixEquip(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_NPC_FIX_ALL: {
							Tools.debugPrintln("Fix bag");
							UINpcShop.recvFixAll(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
						}
							break;
						case GameProtocol.SC_NPC_SHOP_LIST:
							UINpcShop.recvNpcShopInfos(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_NPC_SHOP_BUY:
						case GameProtocol.SC_NPC_SHOP_SAIL:
							UINpcShop.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_NPC_FIX_ENTER:
							UINpcShop.recvOpenFixShop(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_NPC_SAIL_ENTER:
							UINpcShop.recvOpenSailShop(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_NPC_EQUIP_FIX_ALERT:
							recvEquipFixAlert(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						/**** 交易 ****/
						case GameProtocol.CS_DEAL_REQUEST://
							UIDeal.recvRequestSTA(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_DEAL_REQUEST://
							UIDeal.recvRequestSTB(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_DEAL_RESPONESE://
							UIDeal.recvResponseSTA(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_DEAL_RESPONESE://
							UIDeal.recvResponseSTB(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_DEAL_GOODS_LAYUP_SELF://
						case GameProtocol.CS_DEAL_GOODS_LAYDOWN_SELF://
						case GameProtocol.CS_DEAL_MONEY_SELF://
						case GameProtocol.S_DEAL_MONEY_OTHER:
						case GameProtocol.S_DEAL_GOODS_LAYUP_OTHER:
						case GameProtocol.S_DEAL_GOODS_LAYDOWN_OTHER://
						case GameProtocol.CS_DEAL_CONFIG:
						case GameProtocol.S_DEAL_CONFIG://
						case GameProtocol.CS_DEAL_CANCEL:
						case GameProtocol.S_DEAL_CANCEL:
							UIDeal.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						// 聊天信息
						case GameProtocol.CS_CHAT_INFOS:
							recvChatInfos(dis);
							break;
						case GameProtocol.S_CHAT_WORLD_CONFIG:
							recvChatWorld(dis);
							break;
						/**** 邮件 ***/
						case GameProtocol.CS_MAIL_SENDMAIL:
						case GameProtocol.CS_MAIL_ACC:
							UIMail mail = (UIMail) UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_MAIL);
							if (mail != null) {
								mail.recvMessage(order, dis);
							}
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						//
						case GameProtocol.S_MAIL_MAILLIST:
							UIMailList.recvMailList(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_MAIL_MAILDETAIL:
							UIMail.recvMailDetail(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_MAIL_WARN:
							recvMailWarn(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_MAIL_FAMILY:
							UIMail.recvMailFamily(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						// 拍卖
						case GameProtocol.CS_AUCTION_SAIL:
						case GameProtocol.CS_AUCTION_OPEN_SAIL:
							UIAuctionSail.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_AUCTION_SEARCH:
							Tools.debugPrintln("接受搜索拍卖信息");
							UIAuctionList.recvSearch(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_AUCTION_DETAIL:
							// System.err.println("接受拍卖详情信息");
							UIAuctionDetail.recvMessage(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.S_AUCTION_CANCEL:
						case GameProtocol.S_AUCTION_YIKOUJIA:
							UIAuctionList list = (UIAuctionList) UIManager.getInstance().getWindowById(
									UIWindowFactory.WINDOW_AUCTION_LIST);
							if (list != null) {
								list.recvMessage(order, dis);
							}
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						// 技能
						case GameProtocol.SC_SKILL_DETAIL:
							try {
								UISkillDetail.recvMessage(dis);
							}
							catch (Exception e) {
							}
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_COMBAT_SKILL_LIST:
							GameManager.getInstance().m_role.initCombatSkill(dis);
							// updateShortcutAndMarcoOnSkillChanged(dis)
							// ;//重传技能需要更新快捷栏和宏
							// UIMain.updateShortcut();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_LEARN_COMBAT_SKILL:
						case GameProtocol.CS_ABOLISH_COMBAT_SKILL:
							recvLearnCombatSkill(dis);
							GameManager.getInstance().m_game_message.sendMarOnSkillChanged();// 当技能修改时修改数据
							GameManager.getInstance().m_game_message
									.sendSetShortCut(GameManager.getInstance().m_role.m_shortcut);
							UISkill.update();
							UIMain.updateShortcut();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_ABOLISH_ALL_COMBAT_SKILL:
							recvAbolishAllCombatSkill(dis);
							GameManager.getInstance().m_game_message.sendMarOnSkillChanged();
							GameManager.getInstance().m_game_message
									.sendSetShortCut(GameManager.getInstance().m_role.m_shortcut);
							UISkill.update();
							UIMain.updateShortcut();
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_SET_SHORTCUT_SKILL:
							UIMain.updateShortcut();
							break;
						case GameProtocol.SC_UPDATE_BUFF_TIME:
							Tools.debugPrintln("读取更新buf时间!");
							recvUpdateBuffTime(dis);
							break;
						case GameProtocol.SC_UPDATE_MODE:
							Tools.debugPrintln("读取更新mode!");
							recvUpdateMode(dis);
							break;
						case GameProtocol.CS_CAST_SKILL:
							recvCastSkill(dis);
							break;
						case GameProtocol.SC_SING_FORWARD:
							recvSingForward(dis);
							break;
						case GameProtocol.SC_CAST_SKILL_FORWORD:
							recvCastSkillForward(dis);
							break;
						case GameProtocol.SC_NPC_SKILL_FORWARD:
							recvNPCSkillForward(dis);
							break;
						case GameProtocol.CS_CAST_SKILL_MOVE:
							Tools.debugPrintln("读取位移返回信息!");
							recvCastSkillMove(dis);
							break;
						case GameProtocol.SC_BUFFER_UPDATE:
							recvBufferUpdate(dis);
							break;
						case GameProtocol.SC_STATE_UPDATE:
							recvStateUpdate(dis);
							break;
						case GameProtocol.SC_ACTION_UPDATE:
							recvActionUpdate(dis);
							break;
						case GameProtocol.SC_DOT_HOT:
							recvDotOrHotNum(dis);
							break;
						case GameProtocol.SC_NPC_LIST:
							Tools.debugPrintln("获得NPC交互信息!");
							// recvNPCList(dis);
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_npc_window.recvNPCList(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_NPC_INTERACT:
							Tools.debugPrintln("读取NPC互动任务!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_npc_window.recvNPCInteract(dis);
							break;
						case GameProtocol.CS_PET_LIST:
							Tools.debugPrintln("获得宠物列表");
							recvPetList(dis);
							break;
						case GameProtocol.CS_NPC_BUSINESS:
							Tools.debugPrintln("获得商店信息");
							recvBusiness(dis);
							break;
						case GameProtocol.SC_NPC_AUCTION_SAIL: {
							short state = dis.readShort();
							if (state != 0) {
								UIAuction.openMenu();
							}
						}
							break;
						case GameProtocol.SC_TASK_ROLE_VIEW:
							Tools.debugPrintln("读取玩家任务详细信息!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvTaskViewRole(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_TASK_NPC_VIEW:
							Tools.debugPrintln("读取NPC任务详细信息!");
							GameManager.getInstance().m_task_window.recvTaskViewNPC(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_TASK_HINT_PATHFINDING:
							Tools.debugPrintln("读取任务寻路提示!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvTaskHintPathfinding(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_TASK_BEGIN:
							Tools.debugPrintln("读取接受任务!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvTaskBegin(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_TASK_ABORT:
							Tools.debugPrintln("读取放弃任务!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvTaskAbort(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_TASK_FINISH:
							Tools.debugPrintln("读取完成任务!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvTaskFinish(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.CS_TASK_ROLE_LIST:
							Tools.debugPrintln("读取玩家任务列表!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvRoleTaskList(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_TASK_UPDATE_STATUS:
							Tools.debugPrintln("读取更新任务!");
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							GameManager.getInstance().m_task_window.recvTaskUpdateStatus(dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_SOCIAL_LIST:
							Tools.debugPrintln("读取社交列表!");
							UISocialWindow.recvSocialList(dis);
							break;
						case GameProtocol.SC_SOCIAL_ID_ADD:
							Tools.debugPrintln("读取社交列表添加玩家!");
							// recvSocialAdd(dis);
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							UISocialWindow.recvSocialAdd(dis);
							break;
						case GameProtocol.SC_SOCIAL_DELETE:
							Tools.debugPrintln("读取社交列表删除玩家!");
							// recvSocialDelete(dis);
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							UISocialWindow.recvSocialDelete(dis);
							break;
						case GameProtocol.SC_SOCIAL_CONFIRMATION:
							Tools.debugPrintln("读取添加好友确认信息!");
							// recvSocialConfirmation(dis);
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							UISocialWindow.recvSocialConfirmation(dis);
							break;
						case GameProtocol.CS_ROLE_VIEW:
							Tools.debugPrintln("读取玩家信息!");
							recvRoleView(dis);
							break;
						case GameProtocol.CS_NPC_STUDY_LIFE_SKILLS:
							Tools.debugPrintln("读取学习生活技能列表!");
							// recvNPCStudyLifeSkills(dis);
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							// GameManager.getInstance().m_life_skills_window.recvLSStudyList(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_VIEW:
							Tools.debugPrintln("查看生活技能详细信息!");
							// recvLifeSkillsView(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_STUDY:
							Tools.debugPrintln("读取学习生活技能!");
							// recvLifeSkillsStudy(dis);
							break;
						case GameProtocol.CS_NPC_FORGET_LIFE_SKILLS:
							Tools.debugPrintln("读取遗忘生活技能列表!");
							// recvNPCForgetLifeSkills(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_FORGET:
							Tools.debugPrintln("读取遗忘生活技能!");
							// recvLifeSkillsForget(dis);
							// UiManager.getInstance().recvDataFromServer(BaseConnection.s_orderID,
							// dis);
							break;
						case GameProtocol.SC_SOCIAL_AUTOADDFRIEND:
							UIAutoAddFriend.recvAutoAddFriend(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_INTO:
							Tools.debugPrintln("读取进入洞府!");
							// recvLifeSkillsCavesInto(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_QUIT:
							Tools.debugPrintln("读取退出洞府!");
							// recvLifeSkillsCavesQuit(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_UPDATE:
							Tools.debugPrintln("更新生产时间!");
							// recvLifeSkillsCavesUpdate(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_CANCEL:
							Tools.debugPrintln("取消生产技能!");
							// recvLifeSkillsCavesCancel(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_HARVEST:
							Tools.debugPrintln("收获生产技能!");
							// recvLifeSkillsCavesHarvest(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_KNOW:
							Tools.debugPrintln("读取已学生活技能!");
							// recvLifeSkillsCavesProduction(dis);
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_PRODU:
							Tools.debugPrintln("读取使用生产技能!");
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_SELECT:
							Tools.debugPrintln("读取选择生产技能!");
							break;
						case GameProtocol.CS_LIFE_SKILLS_CAVES_SELF_STATUS:
							Tools.debugPrintln("读取洞府状态信息!");
							break;
						case GameProtocol.SC_ROLE_MONEY:
							recvRoleMoney(dis);
							break;
						case GameProtocol.SC_ROLE_EXP:
							recvRoleExp(dis);
							break;
						case GameProtocol.CS_PICKUP_ITEM:
							Tools.debugPrintln("拾取道具返回信息!");
							recvPickItem(dis);
							break;
						// 组队相关
						case GameProtocol.SC_TEAM_SUCCEED:
							Tools.debugPrintln("recv组队是否成功");
							UITeamWindow.recvTeamIsSucceed(dis);
							break;
						case GameProtocol.SC_TEAM_AGREE:
							Tools.debugPrintln("recv组队请求是否同意");
							UITeamWindow.recvTeamIsAgree(dis);
							break;
						case GameProtocol.SC_TEAM_MESSAGE:
							Tools.debugPrintln("recv获得全队信息");
							UITeamWindow.recvTeamInfo(dis);
							break;
						case GameProtocol.SC_TEAM_QUITTEAM:
							Tools.debugPrintln("recv退出队伍是否成功");
							UITeamWindow.recvTeamRequst(dis);
							break;
						case GameProtocol.SC_TEAM_LEADERHANDLE:
							Tools.debugPrintln("recv队长操作SC");
							UITeamWindow.recvTeamLeader(dis);
							break;
						case GameProtocol.SC_TEAM_TEAMAUTOCREATE:
							Tools.debugPrintln("recv自动组队");
							UITeamWindow.recvTeamAutoCreate(dis);
							break;
						case GameProtocol.SC_TEAM_TEAMLEADERCHANGE:
							Tools.debugPrintln("recv队伍变更");
							GameManager.getInstance().m_role.recvTeamLeaderChange(dis);
							break;
						case GameProtocol.SC_TEAM_TEAMNEAR:
							Tools.debugPrintln("recv附近队伍");
							UITeamWindow.recvTeamNearby(dis);
							break;
						case GameProtocol.SC_TEAM_APPLYJOIN:
							Tools.debugPrintln("recv加入队伍");
							UITeamWindow.recvTeamApplyJoin(dis);
							break;
						case GameProtocol.SC_TEAM_SYNCHRO:
							// Tools.debugPrintln("recv队伍同屏3010");
							recvTeamMSG(dis);
							// 坐骑相关
							break;
						case GameProtocol.SC_RIDE_ISSTARTRIDE:
							Tools.debugPrintln("recv是否可以上坐骑");
							GameManager.getInstance().m_role.recvRideIsStart(dis);
							break;
						case GameProtocol.SC_RIDE_OVERRIDE:
							Tools.debugPrintln("recv完成上坐骑");
						    GameManager.getInstance().m_role.recvRideOver(dis);
							break;
						case GameProtocol.SC_RIDE_CLOSERIDE:
							Tools.debugPrintln("recv下坐骑");
							GameManager.getInstance().m_role.recvRideClose(dis);
							break;
						// 仇敌
						case GameProtocol.SC_SOCIAL_ENEMY_ENEMYLIST:
							Tools.debugPrintln("recv仇敌信息");
							UISocialWindow.recvSocialEnemyList(dis);
							break;
						case GameProtocol.SC_SOCIAL_ENEMY_DELETE:
							Tools.debugPrintln("recv仇敌解除");
							UISocialWindow.recvSocialEnemyDelete(dis);
							break;
						case GameProtocol.SC_SOCIAL_ENEMY_ENEMYINFO:
							Tools.debugPrintln("recv仇敌详细信息");
							UISocialWindow.recvSocialEnemyInfo(dis);
							break;
						case GameProtocol.SC_SOCIAL_ENEMY_LOCK:
							Tools.debugPrintln("recv仇敌锁定");
							UISocialWindow.recvSocialEnemyLock(dis);
							break;
						case GameProtocol.SC_SOCIAL_ENEMY_QUERY_POSITION:
							Tools.debugPrintln("recv仇敌具体位置");
							UISocialWindow.recvSocialEnemyPosition(dis);
							break;
						case GameProtocol.SC_SOCIAL_ENEMY_WANTED_POSTER:
							Tools.debugPrintln("recv仇敌发布通缉令");
							UISocialWindow.recvSocialEnemyWanted(dis);
							break;
						// NPC学习采集
						case GameProtocol.SC_LEARN_COLLECTION:
							Tools.debugPrintln("recv学习采集");
							UILearnCollection.recvLearnCollection(dis);
							break;
						case GameProtocol.SC_LEARN_COLLECTION_OK:
							Tools.debugPrintln("recv确定学习采集");
							UILearnCollection.recvLearnCollectionOK(dis);
							break;
						// NPC遗忘采集
						case GameProtocol.SC_FORGET_COLLECTION:
							Tools.debugPrintln("recv遗忘采集");
							UILearnCollection.recvForgetCollection(dis);
							break;
						case GameProtocol.SC_FORGET_COLLECTION_OK:
							Tools.debugPrintln("recv确定遗忘采集");
							UILearnCollection.recvForgetCollectionOK(dis);
							break;
						// 游戏公告
						case GameProtocol.SC_GAME_ANNOUNCEMENT:
							Tools.debugPrintln("recv游戏公告");
							UIAnnouncement.recvAnnouncement(dis);
							break;
						case GameProtocol.SC_GAME_NOTICE_INFO:
							Tools.debugPrintln("recv游戏单元公告");
							UIAnnouncement.recvAnnouncementInfos(dis);
							break;
						// 通缉令
						case GameProtocol.SC_WANTED_INFOS:
						case GameProtocol.SC_WANTED_FILP:
							Tools.debugPrintln("recv通缉令列表");
							UIWanted.recvWantedInfos(dis);
							break;
						case GameProtocol.SC_WANTED_SEE:
							Tools.debugPrintln("recv通缉令查看信息");
							UIWanted.recvWantedSeeInfos(dis);
							break;
						case GameProtocol.SC_WANTED_TARGETPOSITION:
							Tools.debugPrintln("recv通缉令查看目标位置");
							UIWanted.recvWantedCheckTargetPosition(dis);
							break;
						case GameProtocol.SC_WANTED_ADDENEMY:
							Tools.debugPrintln("recv通缉令加为仇敌");
							UIWanted.recvWantedAddEnemy(dis);
							break;
						case GameProtocol.SC_WANTED_MYPUBLISH:
							Tools.debugPrintln("recv通缉令我的发布与翻页");
							UIWanted.recvWantedMyPublishFilp(dis);
							break;
						case GameProtocol.SC_WANTED_RECV:
							Tools.debugPrintln("recv通缉令的接收通缉令");
							UIWanted.recvWantedRecv(dis);
							break;
						// 洞府
						case GameProtocol.SC_DONGFU_INTO_DONGFU:
							Tools.debugPrintln("recv进入洞府");
							UICaveWorldWindow.recvSeedDongFuInfo(dis);
							break;
						case GameProtocol.SC_DONGFU_OUT_DONGFU:
							Tools.debugPrintln("recv退出洞府");
							UICaveWorldWindow.recvOutDongFu(dis);
							break;
						case GameProtocol.SC_DONGFU_REAP_DONGFU:
							Tools.debugPrintln("recv洞府收获道具");
							UICaveWorldWindow.recvReapDongFu(dis);
							break;
						case GameProtocol.SC_DONGFU_getPropMsg:
							Tools.debugPrintln("recv获得洞府");
							UICaveWorldWindow.recvGetPropMsg(dis);
							break;
						case GameProtocol.SC_DONGFU_START_PRODUCTION:
							Tools.debugPrintln("recv开始生产");
							UICaveWorldWindow.recvDongFuStartProduction(dis);
							break;
						case GameProtocol.SC_DONGFU_ADD_SPEED:
							Tools.debugPrintln("recv 洞府加速");
							UICaveWorldWindow.recvDongFuAddSpeed(dis);
							break;
						case GameProtocol.SC_DONGFU_WATERING:
							Tools.debugPrintln("recv 洞府浇灌");
							UICaveWorldWindow.recvDongFuWatering(dis);
							break;
						case GameProtocol.SC_DONGFU_LOOKMSG:
							Tools.debugPrintln("recv 洞府查看");
							UICaveWorldWindow.recvDongFuLookMsgWatering(dis);
							break;
						case GameProtocol.SC_DONGFU_GONGFA:
							Tools.debugPrintln("recv 洞府攻伐");
							UICaveWorldWindow.recvDongFuGongFa(dis);
							break;
						case GameProtocol.SC_DONGFU_GONGFA_MSG:
							Tools.debugPrintln("recv 洞府攻伐记录");
							UICaveWorldWindow.recvDongFuGongFaMSG(dis);
							break;
						case GameProtocol.SC_DONGFU_GONGFALIST:
							Tools.debugPrintln("recv 洞府攻伐列表");
							UISocialWindow.recvDongFuGongFa(dis);
							break;
						case GameProtocol.SC_DONGFU_SPEED_ASK:
							Tools.debugPrintln("recv 洞府加速请求");
							UICaveWorldWindow.recvDongfuSpeedASK(dis);
							break;
						case GameProtocol.SC_DONGFU_SPEEDUP_YUANBAO:
							Tools.debugPrintln("recv 洞府加速付钱");
							UICaveWorldWindow.recvDongfuSpeedUPYuanbao(dis);
							break;
						case GameProtocol.SC_PLAY_TRAILER:
							recvPlayTrailer(dis);
							break;
						case GameProtocol.SC_SET_WEATHER_AND_MUSIC:
							Tools.debugPrintln("recv 设置天气效果和音乐设置");
							recvSetWeatherAndMusic(dis);
							break;
						case GameProtocol.SC_CONTROL_SPELL:
							Tools.debugPrintln("recv 设置符咒开关");
							recvSetSpellSwich(dis);
							break;
						case GameProtocol.SC_CONTROL_GIFT:
							Tools.debugPrintln("recv 设置礼包剩余时间");
							UIMain main = (UIMain) UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_MAIN);
							if(main != null){
								main.recvSetGift(dis);
							}
							break;
						case GameProtocol.SC_SHOWDATA:
							Tools.debugPrintln("recv 显示数据");
							UIShowData data = GameManager.getInstance().m_showData;
							if(data != null){
								data.recvShowData(dis);
							}
							break;
						case GameProtocol.C_TO_EQUIPCANCEL:
							Tools.debugPrintln("recv 请求装备强化消除");
							UIBag.recvToEquipCancel(dis);
							break;
						case GameProtocol.C_CONFIRMATION_EQUIPCANCEL:
							Tools.debugPrintln("recv 确定装备强化消除");
							UIBag.recvComfirmEquipCancel(dis);
							break;
						case GameProtocol.SC_AUTO_HANGUP:
							Tools.debugPrintln("recv 打开挂机界面");
							UIAutoHangUp.recvAutoHangUp(dis);
							break;
						case GameProtocol.SC_OPEN_BUY_TWO:
							Tools.debugPrintln("recv 打开挂机购买多倍经验界面");
							UIAutoHangUp.recvOpenBuyTwo(dis);
							break;
						case GameProtocol.SC_BUY_TWO:
							Tools.debugPrintln("recv 挂机购买多倍确认成功失败");
							UIAutoHangUp.recvBuyTwo(dis);
							break;
						case GameProtocol.SC_REFRESH_TIME:
							Tools.debugPrintln("recv 刷新多倍经验拥有时间");
							UIAutoHangUp.recvUpdateTime(dis);
							break;
						case GameProtocol.SC_OPEN_ACTIVITY_WINDOW:
							Tools.debugPrintln("recv 打开每日任务界面");
							UIActivity.recvActivityInfos(dis);
							break;
						case GameProtocol.SC_ACTIVITY_BUY_TASK:
							Tools.debugPrintln("recv 请求购买任务");
							UIActivity.recvActivityBuyTask(dis);
							break;
						case GameProtocol.SC_ACTIVITY_COMPLETE_TASK:
							Tools.debugPrintln("recv 请求立即完成任务");
							UIActivity.recvActivityCompleteTask(dis);
							break;
						case GameProtocol.SC_ACTIVITY_BUY_TASK_OK:
							Tools.debugPrintln("recv 确认购买任务");
							UIActivity.recvActivityBuyTaskOk(dis);
							break;
						case GameProtocol.SC_ACTIVITY_COMPLETE_TASK_OK:
							Tools.debugPrintln("recv 确认更换任务");
							UIActivity.recvActivityCompleteTaskOk(dis);
							break;
						case GameProtocol.SC_OPEN_FB_ACTIVITY_WINDOW:
							Tools.debugPrintln("recv 副本活动");
							UIFbactivity.recvUIFbactivity(dis);
							break;
						// 排行
						case GameProtocol.SC_RANKINGLIST_FAMILY:
							Tools.debugPrintln("recv 家族排行");
							UIRankingLists.recvFamilyRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_LIVEL:
							Tools.debugPrintln("recv 等级排行");
							UIRankingLists.recvLevelRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_WEALTH:
							Tools.debugPrintln("recv 财富排行");
							UIRankingLists.recvWealthRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_KILL:
							Tools.debugPrintln("recv 击杀排行");
							UIRankingLists.recvKillRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_CONTRIBUTION:
							Tools.debugPrintln("recv 贡献排行");
							UIRankingLists.recvContrbutionRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_MILITARY_EXPLOITS:
							Tools.debugPrintln("recv 战功排行");
							UIRankingLists.recvMilitaryExploitsRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_COLLECTION:
							Tools.debugPrintln("recv 采集排行");
							UIRankingLists.recvCollectionRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_ATTACK:
							Tools.debugPrintln("recv 攻伐排行");
							UIRankingLists.recvAttackRankingList(dis);
							break;
						case GameProtocol.SC_RANKINGLIST_SOCIAL_CONTACT:
							Tools.debugPrintln("recv 社交排行");
							UIRankingLists.recvSocialContactRankingList(dis);
							break;
						case GameProtocol.CS_OPEN_CHONGZHI:
						case GameProtocol.CS_CHONGZHI_MIANER:
						case GameProtocol.CS_CHONGZHI_CONFIG:
						case GameProtocol.CS_QUERY_CHONGZHI:
						case GameProtocol.CS_QUERY_YUANBAO_CONSUME:
							UIChongzhi.recvMessage(order, dis);
							GameManager.getInstance().m_game_message.unlockNetwork();
							break;
						case GameProtocol.SC_ACTORROLE_VIM:
							Tools.debugPrintln("recv 精力值");
							GameManager.getInstance().m_role.recvActorVim(dis);
							break;
						case GameProtocol.SC_ACTORITEM_CHAKANCAILIAO:
							Tools.debugPrintln("recv 查看材料列表");
							UIBag bag = (UIBag) UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_BAG);
							if (bag != null) {
								bag.recvChakancailiao(dis);
							}
							break;
						case GameProtocol.C_OPENLIST_FAMILYSHOP:
							Tools.debugPrintln("recv 查看材料列表");
							UIFamilyWindow win = (UIFamilyWindow) UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_ID_FAMILY);
							if (win != null) {
								win.recvOpenListFamilyShop(dis);
							}
							break;
					}
				}
			}
			dis.close();
			bais.close();
			dis = null;
			bais = null;
		}
		catch (Exception ex) {
		    GameManager gm = GameManager.getInstance();
		    if (gm != null) {
		        if (gm.m_game_message != null) {
		            gm.m_game_message.unlockNetwork();
		        }
		    }
//			GameManager.getInstance().m_game_message.unlockNetwork();
			Tools.debugPrintln("场景处理网络数据异常！！" + BaseConnection.s_perseOrderID);
			Tools.debug(ex);
		}
		return false;
	}

	/**
	 * 接受提示
	 * @param dis
	 * @throws IOException
	 */
	private void recvTeach(DataInputStream dis) throws IOException
	{
		try {
			int num_step = dis.readInt();//步骤
			String[][] des = new String[num_step][];
			int[][] keys = new int[num_step][];
			int[][] keys_skip = new int[num_step][];
			int[][] infos = new int[num_step][];
			byte[] types = new byte[num_step];
			for (int i = 0; i < num_step; i++) {
				String content = dis.readUTF();//提示内容
				int num_key = dis.readInt();//有效按键次数
				keys[i] = new int[num_key];
				for (int j = 0; j < num_key; j++) {
					int temp = dis.readInt();
					keys[i][j] = temp == 0 ? 0 : (1 << temp);//有效按键键值
				}
				int num_skip = dis.readInt();//跳出当前步骤次数
				keys_skip[i] = new int[num_skip];
				for (int j = 0; j < num_skip; j++) {
					int temp = dis.readInt();
					keys_skip[i][j] = temp == 0 ? 0 : (1 << temp);//跳出按键键值
				}
				int num_pos = dis.readInt();//点选位置
				if (num_pos == 0) {//在正中显示文字内容
					types[i] = 0;
					int w = (UITools.W_BG >> 1);//文字框大小，如果要改变宽度，则uimanger中paint也要修改
					des[i] = Tools.getStrArray(content, w - (UITools.IW_RECT_CONTENT << 1));
				}
				else {
					types[i] = 1;
					int index = 0;//选机型
					//#if screen == "320240"
					//# index = 1;//选机型
					//#else
					//# index = 2;//选机型
					//#endif
					for (int j = 0; j < num_pos; j++) {
						int x1 = dis.readInt();
						int y1 = dis.readInt();
						int x2 = dis.readInt();
						int y2 = dis.readInt();
						if (index == j) {
							infos[i] = UITools.getYindaoPar2(x1, y1, x2 - x1, y2 - y1, UITools.W_BG, UITools.H_BG,
									content);
						}
					}
					des[i] = Tools.getStrArray(content, infos[i][11] - (UITools.IW_RECT_CONTENT << 1));
				}
			}
			GameManager gm = GameManager.getInstance();
			gm.m_desc_teach = des;
			gm.m_infos_teach = infos;
			gm.m_keys_teach = keys;
			gm.m_keys_skip_teach = keys_skip;
			gm.m_types_teach = types;
			gm.m_index_teach = 0;
			gm.m_isInTeach = true;
			UIManager.getInstance().removeOtherWindows();
		}
		catch (Exception e) {//教学出异常则跳出教学
			GameManager.getInstance().getOutOfTeach();
			e.printStackTrace();
		}
	}

	/**
	 * 确认提示
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvConfirmationPrompt(DataInputStream dis) throws IOException
	{
		String msg = dis.readUTF();
		final int order = dis.readInt();
		final String key = dis.readUTF();
		final UIMessageBox mb = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		mb.setMessage(msg);
		mb.addListener(new UIListener() {
			public void actionPerformed()
			{
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					GameManager.getInstance().m_game_message.sendFunction(order, key);
					UIManager.getInstance().removeWindow(mb);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(mb);
				}
			}
		});
	}

	/**
	 * 开启兑换礼包
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvGiftBagOpen(DataInputStream dis) throws IOException
	{
		form.deleteAll();
		m_giftbag.setString("");
		m_giftbag.setLabel("兑换码 : ");
		form.append(m_giftbag);
		form.addCommand(ok);
		form.addCommand(back);
		form.setCommandListener(this);
		form.setFormButtons();
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
	}

	private Form form = new Form("兑换大礼包");
	private Command ok = new Command("确定", Command.OK, 1);
	private Command back = new Command("返回", Command.BACK, 1);
	private TextField m_giftbag = new TextField("", "", 20, TextField.ANY);

	/**
	 * 战场旗子
	 *
	 * @param dis
	 * @throws IOException
	 */
	public void recvBattlefieldFlag(DataInputStream dis) throws IOException
	{
		long id = dis.readLong();
		byte flag = dis.readByte();
		Tools.debugPrintln("战场旗子 : " + id + " : " + flag);

		ActorRole role = getRoleByID(id);
		if (role != null) {
			role.m_battlefield_flag = flag;
		}
		else {
			Tools.debugPrintln("没有找到更新旗子的玩家!");
		}
	}

	/**
	 * 修正玩家的坐标 防止加速
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvScenePostionRevise(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("读取加速坐标修正!");
		GameManager.getInstance().m_role.m_posX = dis.readShort();
		GameManager.getInstance().m_role.m_posY = dis.readShort();
		Tools.debugPrintln("修正坐标x,y : " + GameManager.getInstance().m_role.m_posX + " : "
				+ GameManager.getInstance().m_role.m_posY);
	}

	/**
	 * 接收决斗临时改变阵营
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvDuelTempFaction(DataInputStream dis) throws IOException
	{
		long id = dis.readLong();
		byte faction = dis.readByte();
		ActorRole role = getRoleByID(id);
		if (role != null) {
			role.m_gameID = id;
			role.m_faction = faction;
			Tools.debugPrintln("临时改变玩家" + role.m_name + "的阵营为 : " + faction + "!");
			if (role.m_isCasting) {
				role.m_isCasting = false;
				GameManager.getInstance().m_game_message.sendCastCancel();
				role.stopCasting();
				role.stopCastingDescription();
				if (role.m_status != ActorRole.ACTOR_STATUS_ROLE_DEAD) {
					role.setAction(ActorRole.ACTION_STAND * ActorRole.DIRECT_NUM + role.m_direct, 0, 0, true, false);
				}
			}
		}
		else {
			Tools.debugPrintln("决斗临时改变阵营失败,没有找到id为" + id + "的玩家!");
		}
	}

	/**
	 * 接收询问是否同意决斗
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvDuelQuery(DataInputStream dis) throws IOException
	{
		String name = dis.readUTF();
		final long id = dis.readLong();
		final UIMessageBox mb = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		mb.setMessage("玩家" + name + "向您提出切磋,是否同意?");
		mb.addListener(new UIListener() {
			public void actionPerformed()
			{
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					GameManager.getInstance().m_game_message.sendDuelConfirmation(id, (byte) 1);
					UIManager.getInstance().removeWindow(mb);
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					GameManager.getInstance().m_game_message.sendDuelConfirmation(id, (byte) 0);
					UIManager.getInstance().removeWindow(mb);
				}
			}
		});
	}

	/**
	 * 读取决斗倒计时
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvDuelCountDown(DataInputStream dis) throws IOException
	{
		byte time = dis.readByte();
		GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "决斗倒计时" + time);
	}

	/**
	 * 设置符咒开关效果
	 *
	 * @author zhao
	 * */
	private void recvSetSpellSwich(DataInputStream dis) throws IOException
	{
		int num = dis.readInt();
		// if (num == -1) {// 开启符咒设置功能
		// UIMain.s_spell_type = 1;// 设置为默认显示关
		// return;
		// }
		// else if (num == -2) {// 数量已经为0 不能打开
		// GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B,
		// "没有符咒！");
		// return;
		// }
		// if ( num == 0 ) {// 数量为0关闭
		// UIMain.s_spell_type = -1;
		// UIMain.s_spell_switch = 0;
		// }
		// else {
		// UIMain.s_spell_type = -1;
		// UIMain.s_spell_switch = 1;
		// }
		UIMain.s_spell_num = num;
		Tools.debugPrintln("recvSetSpellSwich 接收符咒数量=" + UIMain.s_spell_num);
	}

	/**
	 * 设置天气效果
	 *
	 * @author zhao
	 * */
	private void recvSetWeatherAndMusic(DataInputStream dis) throws IOException
	{
		byte type = dis.readByte();// 设置天气类型
		byte musicID = dis.readByte();// 设置场景音乐
		Tools.debugPrintln("天气=" + type + ":音乐=" + musicID);
		int colour = 0;
		switch (type) {
			case 0:// 晴天
			default:
				break;
			case 1:// 白雨
			case 3:// 白雪
				colour = 0xFFFFFF;
				break;
			case 2:// 红雨
			case 4:// 红雪
				colour = 0xFF0000;
				break;

		}
		if (GameManager.getInstance().m_scene != null) {
			GameManager.getInstance().m_scene.m_effectId |= (1 << type);
			GameManager.getInstance().m_scene.m_effectColour = colour;
		}
		if (musicID < Music.BG_MUSIC_COVER || musicID > Music.BG_MUSIC_WAR) {
			if (Music.getInstance().isSoundOn()) {// 如果音乐开启
				if (Music.getInstance().getCurBackGroundId() != musicID) {// 如果需要换音乐
					Music.getInstance().loadBackground(Music.SOUND_BG_FILE_NAME, musicID);
					Music.getInstance().playBackground();
				}
			}
			else {// 如果音乐关闭中 只设置音乐ID
				Music.getInstance().setCurBackGroundId(musicID);
			}
		}
	}

	/**
	 * 系统提示 2012-3-12 下午04:05:03 venizeng
	 *
	 * @param dis
	 */
	public static void recvSysInfo(DataInputStream dis)
	{
		String string = null;
		try {
			string = dis.readUTF();
			if (string.equals("")) {
				return;
			}
		}
		catch (Exception e) {
			Tools.debug(e);
			return;
		}
		final UIMessageBox messageBox = (UIMessageBox) UIWindowFactory.createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		try {
			messageBox.setMessage("提示", string);
		}
		catch (Exception e) {
			Tools.debugPrintln("SysInfo = " + string);
			Tools.debug(e);
			return;
		}
		UIManager.getInstance().addWindow(messageBox);
		messageBox.addListener(new UIListener() {

			public void actionPerformed()
			{
				if (AbstractGameScreen.anyKeyPressed()) {
					UIManager.getInstance().removeWindow(messageBox);
				}
			}
		});
	}

	/**
	 * 同步队伍消息3010
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvTeamMSG(DataInputStream dis) throws IOException
	{
		int memberNum = dis.readInt(); // 队员数量
		Vector rolelist = GameManager.getInstance().m_role.m_roleTeam;
		// Tools.debugPrintln("队伍同屏输出：自己的ID" +
		// GameManager.getInstance().m_role.m_gameID);
		for (int i = 0; i < memberNum; i++) {
			long gameID = dis.readLong(); // 队员ID
			byte online = dis.readByte();
			int maxHp = 0, hp = 0, x = 0, y = 0;
			if (online == 0) {
				maxHp = dis.readInt();
				hp = dis.readInt();
				x = dis.readInt();
				y = dis.readInt();
			}
			for (int j = 0; j < rolelist.size(); j++) {
				ActorRole role = (ActorRole) rolelist.elementAt(j);
				if (gameID == role.m_gameID) {
					// role.m_online = (dis.readByte() == 0 ? true : false);
					if (online == 0) {
						role.m_hpMax = maxHp;
						role.m_hp = hp;
						role.m_posX = x;
						role.m_posY = y;
					}
				}
			}
		}
	}

	/**
	 * 互动打断指令
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvNPCInteractBreak(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("读取打断指令!" + m_interact_start);
		if (m_interact_start) {
			endNPCInteract();
			GameManager.getInstance().m_role.stopCasting();
			GameManager.getInstance().m_role.stopCastingDescription();
		}
	}

	/**
	 * 世界寻路
	 *
	 * @param dis
	 * @throws IOException
	 */
	public void recvScenePathfinding(DataInputStream dis) throws IOException
	{
		short status = dis.readShort();
		String msg = dis.readUTF();
		if (status == 1) {
			ActorRole role = GameManager.getInstance().m_role;
			if (role.isAliveStatus()) {
				role.clearPathfinding();
				role.m_pathfinding_id = dis.readLong();
				int size = dis.readInt();
				if (size > 0) {
					role.m_pathfinding_label = 0;
					role.m_pathfinding_point = null;
					role.m_pathfinding_point = new ArrayList();
					Tools.debugPrintln("坐标长度 : " + size);
					for (int i = 0, x = 0, y = 0; i < size; i++) {
						x = dis.readInt();
						y = dis.readInt();
						Tools.debugPrintln("第" + i + "维 : " + x + " : " + y);
						role.m_pathfinding_point.addElement(new Integer(x | (y << 16)));
					}
					role.m_pathfinding_start = true;
					role.m_pathfinding_pause = false;
					role.clearFollowTarget();
				}
				GameManager.getInstance().m_role.stay(GameManager.getInstance().m_role.m_direct);
				UIManager.getInstance().removeOtherWindows();
				Tools.debugPrintln("读取寻路成功!" + role.m_pathfinding_id);
			}
		}
		else {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, msg);
		}
	}

	public void recvPlayTrailer(DataInputStream dis) throws IOException
	{
		if (!m_script.m_trailerEnd || m_script.m_trailerData == null || m_script.m_trailerData.length == 0)
			return;
		m_script.m_curTrailerId = dis.readByte();
		m_script.m_trailerEnd = false;
	}

	/**
	 * 新手引导学习技能 2012-3-8 下午07:22:43 venizeng
	 *
	 * @param dis
	 */
	private void recvPlayLearnSkill(DataInputStream dis)
	{
		String temp = null;
		try {
			temp = dis.readUTF();
		}
		catch (IOException e) {
			Tools.debugPrintln("新手引导学习技能错误:" + temp);
			return;
		}

		long skillId = 0;
		try {
			skillId = Long.parseLong(temp);
		}
		catch (Exception e2) {
			Tools.debugPrintln("新手引导学习技能错误:" + temp);
			return;
		}

		UIMain.gotoTeachLearnSkill(skillId);
	}

	private void recvPlaySetSkill(DataInputStream dis) throws IOException
	{
		byte pos = dis.readByte();
		String temp = null;
		try {
			temp = dis.readUTF();
		}
		catch (IOException e) {
			Tools.debugPrintln("新手引导学习技能错误:" + temp);
			return;
		}
		long skillId = 0;
		try {
			skillId = Long.parseLong(temp);
		}
		catch (Exception e2) {
			Tools.debugPrintln("新手引导学习技能错误:" + temp);
			return;
		}
		UIMain.gotoTeachSetShortcut(pos, skillId);
	}

	/**
	 * 2012-3-8 下午07:22:40 venizeng
	 *
	 * @param dis
	 */
	private void recvPlayTaughtEquip(DataInputStream dis)
	{
		String temp = null;
		try {
			temp = dis.readUTF();
		}
		catch (IOException e) {
			Tools.debugPrintln("新手引导装备ID错误:" + temp);
			return;
		}

		// long euqipId = 0;
		// try {
		// euqipId = Long.parseLong(temp);
		// } catch (Exception e2) {
		// Tools.debugPrintln("新手引导装备ID错误 :" + temp);
		// return;
		// }

		UIMain.gotoTeachEquip(temp);
	}

	// ////////////////////////////////////////////////////////////////
	// // 提示信息相关(无消息框，仅在屏幕上绘制字符串)
	public ArrayList m_messages = new ArrayList();
	public int m_curMessageColorWord;
	public int m_curMessageColorShadow;
	public String m_curMessageContent;
	public int m_curMessageFrameCounter;
	public static final int MESSAGE_DURATION = 40;

	/**
	 * 添加提示消息
	 *
	 * @param content
	 * @param color
	 */
	public void addMessage(String content, int colorWord, int colorShadow)
	{
		m_curMessageContent = content;
		m_curMessageColorWord = colorWord;
		m_curMessageColorShadow = colorShadow;
		m_curMessageFrameCounter = MESSAGE_DURATION;

		// StringBuffer message = new StringBuffer(content);
		// message.append('$');
		// message.append(colorWord);
		// message.append('$');
		// message.append(colorShadow);
		// m_messages.addElement(message.toString());
	}

	/**
	 * 初始化将要显示的提示消息
	 */
	public void initMessage()
	{
		if (m_messages.size() <= 0)
			return;
		String message = (String) m_messages.elementAt(0);
		String[] info = Tools.splitString(message, '$');
		m_curMessageColorWord = Integer.parseInt(info[1]);
		m_curMessageColorShadow = Integer.parseInt(info[2]);
		m_curMessageContent = info[0];
		m_curMessageFrameCounter = MESSAGE_DURATION;
		m_messages.removeElementAt(0);
	}

	/**
	 * 显示提示信息
	 *
	 * @param g
	 */
	public void showMessage(Graphics g)
	{
		if (m_curMessageFrameCounter > 0) {
			g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
			Tools.drawString(g, m_curMessageColorWord, m_curMessageColorShadow, m_curMessageContent,
					AbstractGameScreen.SCREEN_WIDTH / 2, AbstractGameScreen.SCREEN_HEIGHT / 6,
					Graphics.TOP | Graphics.HCENTER);
			m_curMessageFrameCounter--;
		}
		// else {
		// if (m_messages.size() > 0) {
		// initMessage();
		// }
		// }
	}

	// private void showSysMessage(Graphics g){
	//
	// }

	// // 提示信息相关
	// ////////////////////////////////////////////////////////////////

	// ////////////////////////////////////////////////////////////////
	// // 静态图片相关
	public static Image s_img_num;
	public static final String URL_IMG_NUM = "/img/num.png";
	public static final int[] SIZE_IMG_NUM = { 5, 7 };

	public static Image[] s_img_damageNum;
	public static final String[] URL_IMG_DAMAGENUM = { "/img/num1.png", "/img/num2.png", "/img/num3.png",
			"/img/num4.png", "/img/miss.png" };
	public static final int[][] SIZE_IMG_DAMAGENUM = { { 13, 13 }, { 9, 9 }, { 13, 13 }, { 9, 9 }, { 31, 14 } };

	public static Image s_img_icon; // 图标
	public static final String URL_IMG_ICON = "/img/80tubiao.png";
	public static Image s_img_icon_cover; // 图标遮罩
	public static final String URL_IMG_ICON_COVER = "/img/zhezhao.png";
	public static final int[] SIZE_IMG_ICON = { 18, 18, 10 }; // 图块长，图块宽，图块column
	// public static final int[] SIZE_IMG_ICON_COVER = {18 ,18, 10};

	public static Image s_img_cursor_corner = null;
	public static Image s_img_cursor_side = null;

	public static Image[] s_img_v_icon = null;// VIP图标
	public static Image[] s_img_th_icon = null;// 缩略图状态图标
	public static Image[] s_img_f_icon = null;
	public static Image[] s_img_z_icon = null;// 阵营图标
	public static final byte ZHEN_ICON_DT = 0;// 阵营图标 - 洞庭
	public static final byte ZHEN_ICON_KL = 1;// 阵营图标 - 昆仑
	public static final byte ZHEN_ICON_TS = 2;// 阵营图标 - 泰山
	public static final byte VIP_ICON_AMOUNT = 6;// vip总数
	// //图块长，图块宽，图块column
	public static Image s_img_map_bg = null;// 小地图背景
	public static final String URL_IMG_MAP_BG = "/img/mapbg.png";
	public static Image s_img_map_place = null;// 小地图名称
	public static final String URL_IMG_MAP_PLACE = "/img/map_dizhi.png";
	public static Image s_img_map_coord = null;// 小地图坐标
	public static final String URL_IMG_MAP_COORD = "/img/map_zuobiao.png";

	// // 静态图片相关
	// ////////////////////////////////////////////////////////////////

	// ////////////////////////////////////////////////////////////////
	// // 伤害数字相关
	public ArrayList m_damageNum_list = new ArrayList();
	public static final int DAMAGE_NUM_IMGID = 0;
	public static final int DAMAGE_NUM_X = 1;
	public static final int DAMAGE_NUM_Y = 2;
	public static final int DAMAGE_NUM_W = 3;
	public static final int DAMAGE_NUM_H = 4;
	public static final int DAMAGE_NUM_VALUE = 5;
	public static final int DAMAGE_NUM_DURATION = 6;

	public static final int DAMAGE_NUM_IMGID_MISS = 4;

	/**
	 * 添加伤害数字
	 *
	 * @param info
	 */
	public void addDamageNum(int[] info)
	{
		if (info == null)
			return;
		m_damageNum_list.addElement(info);
	}

	/**
	 * 显示伤害数字
	 *
	 * @param g
	 */
	public void showDamageNum(Graphics g)
	{
		int[] info;
		for (int i = 0; i < m_damageNum_list.size(); i++) {
			info = (int[]) m_damageNum_list.elementAt(i);
			if (info[DAMAGE_NUM_IMGID] == DAMAGE_NUM_IMGID_MISS) {
				Tools.drawImage(g, s_img_damageNum[info[DAMAGE_NUM_IMGID]], info[DAMAGE_NUM_X], info[DAMAGE_NUM_Y]--,
						info[DAMAGE_NUM_W], info[DAMAGE_NUM_H],
						Graphics.TOP | Graphics.HCENTER);
			}
			else {
				Tools.drawNumber(g, s_img_damageNum[info[DAMAGE_NUM_IMGID]], info[DAMAGE_NUM_X], info[DAMAGE_NUM_Y]--,
						info[DAMAGE_NUM_W], info[DAMAGE_NUM_H],
						info[DAMAGE_NUM_VALUE], 1, Graphics.TOP | Graphics.HCENTER, true);
			}
			if (info[DAMAGE_NUM_DURATION]-- < 0) {
				m_damageNum_list.removeElememt(info);
			}
		}
	}

	public ArrayList m_damageMiss_list = new ArrayList();
	public static Image s_img_miss;

	// // 伤害数字相关
	// ////////////////////////////////////////////////////////////////

	// ////////////////////////////////////////////////////////////////
	// // 光效相关
	public static final int EFFECT_MAX_NUM = 20;
	public ArrayList m_effects = new ArrayList(EFFECT_MAX_NUM, 5);

	/**
	 * 添加光效
	 *
	 * @param x
	 * @param y
	 */
	public GameEffect addEffect(int id, int x, int y)
	{
		if (id < 0)
			return null;
		GameEffect effect = null;
		if (m_effects.size() < EFFECT_MAX_NUM) {
			effect = (GameEffect) (GameEffect.s_effect.clone());
			effect.init(x, y, id, true, GameEffect.DURATION_NONE);
			m_effects.addElement(effect);
			return effect;
		}
		removeEarliestEffect();
		effect = (GameEffect) (GameEffect.s_effect.clone());
		effect.init(x, y, id, true, GameEffect.DURATION_NONE);
		m_effects.addElement(effect);
		return effect;
	}

	public GameEffect addEffect(int id, int x, int y, int duration, boolean doKeyFrame)
	{
		if (id < 0)
			return null;
		GameEffect effect = null;
		if (m_effects.size() < EFFECT_MAX_NUM) {
			effect = (GameEffect) (GameEffect.s_effect.clone());
			effect.init(x, y, id, doKeyFrame, duration);
			m_effects.addElement(effect);
			return effect;
		}
		removeEarliestEffect();
		effect = (GameEffect) (GameEffect.s_effect.clone());
		effect.init(x, y, id, doKeyFrame, duration);
		m_effects.addElement(effect);
		return effect;
	}

	/**
	 * 移除最早的光效
	 */
	public void removeEarliestEffect()
	{
		int frameLeft = Integer.MAX_VALUE;
		int index = -1;
		GameEffect effect;
		for (int i = 0; i < m_effects.size(); i++) {
			effect = (GameEffect) m_effects.elementAt(i);
			if (!effect.m_enabled) {
				index = i;
				break;
			}
			if (effect.getFrameLeft() < frameLeft) {
				frameLeft = effect.getFrameLeft();
				index = i;
			}
		}
		if (index != -1) {
			effect = (GameEffect) m_effects.elementAt(index);
			effect.doKeyFrame();
			m_effects.removeElementAt(index);
		}
	}

	/**
	 * 移除指定的光效
	 *
	 * @param effect
	 */
	public void removeEffect(GameEffect effect)
	{
		if (effect == null || m_effects.size() == 0)
			return;
		for (int i = 0; i < m_effects.size(); i++) {
			if (effect == (GameEffect) m_effects.elementAt(i)) {
				m_effects.removeElementAt(i);
				return;
			}
		}
	}

	/**
	 * 显示光效，执行光效逻辑
	 *
	 * @param g
	 */
	public void showEffect(Graphics g)
	{
		GameEffect effect;
		for (int i = 0; i < m_effects.size(); i++) {
			effect = (GameEffect) m_effects.elementAt(i);
			if (!effect.m_enabled) {
				m_effects.removeElementAt(i--); // 避免跳过下个effect
				continue;
			}
			// effect.updatePos();
			// effect.logic();
			effect.draw(g, m_cameraX, m_cameraY);
			effect.nextFrame();
		}
	}

	// // 光效相关
	// ////////////////////////////////////////////////////////////////

	// /////////////////////////////////////////////////////////////
	// // 目标相关
	public ArrayList m_targetFriendList = new ArrayList(); // 已方目标列表
	public ArrayList m_targetEnemyList = new ArrayList(); // 敌方目标列表
	public static int TARGET_RANGE = 90; // 选择范围 法师145, 剑士90, 刀客90

	public void initTargetList()
	{
		if (m_targetFriendList == null)
			m_targetFriendList = new ArrayList();
		if (m_targetEnemyList == null)
			m_targetEnemyList = new ArrayList();
	}

	/**
	 * 选择目标
	 */
	public AbstractGameActor changeTargetActor(boolean isFriend, boolean isAuto)
	{
		AbstractGameActor ar = null;
		AbstractGameActor targetActor = null;
		Actor actor;
		ArrayList list = isFriend ? m_targetFriendList : m_targetEnemyList;
		int last = Integer.MAX_VALUE;
		for (int i = 0, range = 0; i < m_dynamic_actors.size(); i++) {
			actor = (Actor) m_dynamic_actors.elementAt(i);
			if (actor == null)
				continue;
			// 玩家自身
			if (isAuto && actor == m_controlledActor)
				continue;
			// 不符合要求的Actor类型
			if (!(actor instanceof ActorRole || actor instanceof ActorNPC))
				continue;
			ar = (AbstractGameActor) actor;
			// 根据类型进行筛选
			if (ar.m_type == AbstractGameActor.ACTOR_TYPE_ITEM || ar.m_type == AbstractGameActor.ACTOR_TYPE_GATE
					|| ar.m_type == AbstractGameActor.ACTOR_TYPE_RELIVE
					|| ar.m_type == AbstractGameActor.ACTOR_TYPE_MAPPOINT
					|| ar.m_type == AbstractGameActor.ACTOR_TYPE_FAZHEN) {
				continue;
			}
			// 根据是否友好进行一些筛选
			if (isFriend) {// 友好 #
				if (ar.m_type != AbstractGameActor.ACTOR_TYPE_ROLE || !m_controlledActor.checkTargetFriend(ar)) {
					continue;
				}
			}
			else {// 敌对 *
				if (ar.m_type == AbstractGameActor.ACTOR_TYPE_ROLE && m_controlledActor.checkTargetFriend(ar)) {
					continue;
				}
			}
			// 根据状态进行筛选
			if (ar.m_status == AbstractGameActor.ACTOR_STATUS_ROLE_DEAD) {
				if (!m_controlledActor.checkTargetFactionRole(ar)) {
					continue;
				}
			}
			if (ar.m_status == AbstractGameActor.ACTOR_STATUS_NPC_DEAD) {
				continue;
			}
			range = (ar.m_posX - m_controlledActor.m_posX) * (ar.m_posX - m_controlledActor.m_posX)
					+ (ar.m_posY - m_controlledActor.m_posY)
					* (ar.m_posY - m_controlledActor.m_posY);
			// 距离大于选择范围的直接无视
			if (range > TARGET_RANGE * TARGET_RANGE) {
				continue;
			}
			if (!ar.m_needDraw || !ar.m_enabled || !ar.m_visible) {
				continue;
			}
			// 已经在已选目标列表中的，优先级排后
			if (list.contain(ar)) {
				range += TARGET_RANGE * TARGET_RANGE;
			}
			if (range < last) {
				last = range;
				targetActor = ar;
			}
		}
		if (last == Integer.MAX_VALUE) {
			return m_controlledActor.m_targetActor;
		}
		// 当前身边的所有人都已经被选中过了，清空目标列表
		else if (last >= TARGET_RANGE * TARGET_RANGE) {
			list.removeAllElements();
		}
		GameManager.getInstance().m_role.clearAutoAttack();
		Tools.debugPrintln("设置目标ID : " + targetActor.m_gameID);
		setTargetActor(targetActor);
		if (!list.contain(m_controlledActor.m_targetActor)) {
			list.addElement(m_controlledActor.m_targetActor);
		}
		return targetActor;
	}

	/**
	 * 设置targetActor
	 *
	 * @param actor
	 */
	public void setTargetActor(AbstractGameActor actor)
	{
		m_controlledActor.m_targetActor = actor;
		if (actor == null) {
			Tools.debugPrintln("清空目标!");
			ActorRole role = GameManager.getInstance().m_role;
			if (role.m_isCasting) {
				role.m_isCasting = false;
				GameManager.getInstance().m_game_message.sendCastCancel();
				role.stopCasting();
				role.stopCastingDescription();
				if (role.m_status != ActorRole.ACTOR_STATUS_ROLE_DEAD) {
					role.setAction(ActorRole.ACTION_STAND * ActorRole.DIRECT_NUM + role.m_direct, 0, 0, true, false);
				}
			}
			m_targetFriendList.removeAllElements();
			m_targetEnemyList.removeAllElements();
		}
		GameManager.getInstance().m_role.clearAutoAttack();
		GameManager.getInstance().m_role.stopMacro();
		UIMain.updateTarget();
	}

	public void commandAction(Command arg0, Displayable arg1)
	{
		if (arg0 == ok) {
			if (m_giftbag.getString() != null && !m_giftbag.getString().equals("")) {
				GameManager.getInstance().m_game_message.sendGiftBagExchange(m_giftbag.getString());
				Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			}
		}
		else if (arg0 == back) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		}
	}

	// //目标相关
	// ////////////////////////////////////////////////////////////
}
